Professional Documents
Culture Documents
Priyac 2
Priyac 2
Priyac 2
PROGRAMMING IN
EMBEDDED SYSTEMS
ASSIGNMENT-1
~A PROJECT BY
S.PRIYANKA-200051601025
INDEX
1. MANIPULATION 3-6
OF BITS
2. SIZE OF DATA 7-8
TYPES
3. LOOPS 9-10
4. CALLING A 11-13
FUNCTION
5. CONDITIONAL 13
OPERATOR
6. SWITCH CASE 14-15
7. ARRAY 15-16
8. MATRIX 17-20
MULTIPLICATION
9. POINTERS 20-21
#include <stdio.h>
int main() {
int a,b,c;
printf("enter a number");
scanf("%d",&a);
scanf("%d",&b);
c=1<<b;
a=a&c;
if(a==0)
else
return 0;
OTPUT:
INVERTING A BIT:
PROGRAM:
// TINVERTING THE BITS
#include <stdio.h>
int main() {
int a,b,c;
printf("enter a number");
scanf("%d",&a);
scanf("%d",&b);
b=a^(1<<b);
return 0;
OUTPUT:
CLEARING A BIT:
PROGRAM:
#include <stdio.h>
int main() {
int a,b,c;
printf("enter a number");
scanf("%d",&a);
scanf("%d",&b);
b=a&(~(1<<b));
return 0;
OUTPUT:
EXTRACTING A BIT:
PROGRAM:
/ EXTRACTING THE BITS
#include <stdio.h>
int main() {
int a,b,c;
printf("enter a number");
scanf("%d",&a);
scanf("%d",&b);
b=(a&(1<<b))>>b;
return 0;
OUTPUT:
SETTING A BIT:
PROGRAM:
// setting THE BITS
#include <stdio.h>
int main() {
int a,b,c;
printf("enter a number");
scanf("%d",&a);
scanf("%d",&b);
b=a|(1<<b);
return 0;
OUTPUT:
2.Size of data types:
program:
// size of data type
#include <stdio.h>
int main() {
int i=5;
float j=7;
char k=1;
//adress
return 0;
OTPUT:
3.LOOPS
FOR LOOP:
Program:
// for looop
#include <stdio.h>
int main() {
int i=5;
for(i=0;i<=11;i++)
printf("%d",i);
return 0;
OUTPUT:
WHILE LOOP:
Program:
// Online C compiler to run C program online
#include <stdio.h>
int main() {
int var=5;
while(var<=10)
printf("%d",var);
var++;
return 0;
}
Output:
DO WHILE:
Program:
/ DO while
#include <stdio.h>
int main() {
int i=5;
do{
printf("%d",i);
i++;
while(i<10);
return 0;
OUTPUT:
4.CALLING A FUNCTION:
Swapping of two numbers : call by value
Program:
/swapping two numbers by call by value
#include <stdio.h>
int main()
int a = 10;
int b = 20;
printf("Before swapping the values in main a = %d, b = %d\n",a,b); // printing the value of a and b
in main
swap(a,b);
printf("After swapping values in main a = %d, b = %d\n",a,b); // The value of actual parameters do
not change by changing the formal parameters in call by value, a = 10, b = 20
int temp;
temp = a;
a=b;
b=temp;
Output:
#include<stdio.h>
(*num) += 100;
int main() {
int x=100;
return 0;
OUTPUT:
5.CONDITIONAL OPERATOR:
PROGRAM:
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
(num % 2 == 0)? printf("The given number is even") : printf("The given number is odd");
return 0;
OUTPUT:
6.SWITCH CASE:
PROGRAM:
// Program to create a simple calculator
#include <stdio.h>
int main() {
char operation;
scanf("%c", &operation);
switch(operation)
case '+':
break;
case '-':
break;
case '*':
printf("%.1lf * %.1lf = %.1lf",n1, n2, n1*n2);
break;
case '/':
break;
default:
return 0;
OUTPUT:
7. ARRAY:
PROGRAM:
#include <stdio.h>
int main() {
OUTPUT:
scanf("%d", &matrix[i][j]);
int second[][10],
int result[][10],
result[i][j] = 0;
if (j == column - 1)
printf("\n");
int main() {
return 0;
OUTPUT:
9.POINTERS:
PROGRAM:
#include <stdio.h>
int main()
int* pc, c;
c = 22;
pc = &c;
c = 11;
*pc = 2;
return 0;
OUTPUT:
10.STRUCTURE:
PROGRAM:
#include <string.h>
struct Person {
char name[50];
int citNo;
float salary;
} person1;
int main() {
person1.citNo = 1984;
return 0;
OUTPUT:
11.PROGRAM TO FPRM PYRAMID OF STARS:
PROGRAM:
#include <stdio.h>
void main() {
int i,j,rows,k;
printf("enter a number");
scanf("%d",&rows);
printf("\n");
for(i=1;i<=rows;i++)
{
printf("");
for(j=1;j<=rows;j++){
}
for(k=i;k<=rows;k++)
{
printf("*");//print the start
}
printf("\n");
}
}
OUTPUT: