C PROGRAM
24AFECE156
#include<stdio.h>
#include<conio.h>
int main()
int a;
float b;
char c;
double d;
printf("size of int : %u\n",sizeof(a));
printf("size of char : %u\n",sizeof (c));
printf("size of float : %u\n",sizeof(b));
printf("size of double: %u\n",sizeof(d));
return 0;
O\P:
Size of int:4
Size of char:1
Size of float:4
Size of double:8
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int p,t,r,si;
printf("enter price,time and rate of simple interest:\n");
scanf("%d%d%d",&p,&t,&r);
si=(p*t*r)/100;
printf("simple interest=%d",si);
return 0;
i\p:Enter p,t,r, values are 20,30,40
o\p: the value of si =240
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
float length,width,area;
printf("enter the lenth of the rectangle:");
scanf("%f",&length);
printf("enter width of the rectangle:");
scanf("%f",&width);
area=length*width;
printf("the area of the rectangle is :%f\n",area);
return 0;
i\p:
enter the length of rectangle=5
enter the width of the rectangle=3
o\p:
area of rectangle=15
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a,b;
printf("enter two numbrs");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("after swapping:a=%d,b=%d\n",a,b);
return 0;
i\p:
enter two numbrs 1,2
o\p:
after swapping a=2, b=1
C PROGRAM
24AFECE156
#include<stdio.h>
#include<conio.h>
int main()
int x,y;
float salary=13.48;
char letter='k';
x=25; y=34;
int z=x+y;
printf("%d\n",z);
printf("%f\n",salary);
printf("c\n",letter);
return 0;
Input\output:
59
13.480000
K
C PROGRAM
24AFECE156
#include<stdio.h>
#include<conio.h>
int main()
int q=9;
const int a=10;
q=15;
//a=100;
printf("q=%d\n,a=%d",q,a);
return 0;
o\p:
q=5
a=10
C PROGRAM
24AFECE156
#include<stdio.h>
#include<conio.h>
int main() {
char chr;
printf("enter a charecter:");
scanf("%c",&chr);
printf("you entered%c\n",chr);
printf("ASCII value is%d",chr);
return 0;
o\p:
enter a character :g
you entred g
ASCII value is 103
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
//write c code here
int a=10,b=5,c=3,d=2,e=6,f=7,g=5,result;
result=a+b*c+(d*e)*f*g;
printf("result is %d",result);
return 0;
o\p:
result is +2
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
//write c code here
int a=10,b=5,result;
result=a+++b---a;
printf("result is %d",result);
return 0;
o\p:
result is 4
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a=10,b=5,c=3,d=2,result;
result=a/b*c-b+a*d/3;
printf("result is %d",result);
return 0;
o\p:
result is 7
C PROGRAM
24AFECE156
#include<stdio.h>
int main(){
int a,b,add,sub,mul,div,mod;
printf("enter a and b values");
scanf("%d%d",&a,&b);
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
mod=a%b;
printf("addition value is :%d\n",add);
printf("substraction value is :%d\n",sub);
printf("multiplication value is :%d\n",mul);
printf("division value is :%d\n",div);
printf("modular division value is :%d\n",mod);
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a=10,b=20;
printf("a==b:%d\n",a==b);
printf("a!=b:%d\n",a!=b);
printf("a>b:%d\n",a>b);
printf("a<b:%d\n",a<b);
printf("a>=b:%d\n",a>=b);
printf("a<=b:%d\n",a<=b);
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main(){
int a=5;
int b=1;
int result;
result=a&b;
printf("a^&b=%d\n",result);
result=a/b;
printf("a/b=%d\n",result);
result=a<<b;
printf("a<<1=%d\n",result);
result=a>>b;
printf("a>>b=%d\n",result);
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a=10,b=20;
int result;
result=(a>b)?a:b;
printf("the maximum value is:%d\n",result);
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a=10,b=20,c;
printf("c=a+b:%d\n",c);
c+=a;
printf("c+=a:%d\n",c);
c-=b;
printf("c-=b:%d\n",c);
c*=a;
printf("c*=a:%d\n",c);
c/=a;
printf("c/=a:d\n",c);
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int a=5,b=20,c;
if(a&&b)
printf("line 1 condition is true\n");
if(a||b)
printf("line 2 condition is true\n");
a=0;
b=10;
if(a&&b)
printf("line 3 conditoin is true\n");
else
{
C PROGRAM
24AFECE156
printf("line 3 condition is true\n");
if(!(a&&b))
printf("line 4 condition is true\n");
return 0;
}
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int num=5;
float f=num;
printf("implicit convension:int %d to float %2 f\n",num,f);
return 0;
o\p:
5
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
double x=1.2;
int sum=(int)x+1;
printf("sum=%d",sum);
return 0;
o\p:
1.2+1=2.2=2
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=10;
if(i>15);
printf("10 is greater than 15");
printf("i am Not in if");
return 0;
o\p:
I am not in if
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=20;
if(i<15)
printf("i is smaller than 15");
else
printf("i is greater than 15");
return 0;
o\p:
I is greater than 15
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=20;
if(i==10)
printf("i is 10");
else if(i==15)
printf("i is 15");
else if(i==20)
printf("i==20");
else
printf("i is not present");
return 0;
o\p:
i is 20
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=10;
if(i==10)
if(i<15)
printf("i is smaller than 15\n");
if(i<12)
printf("i is smaller than 12 too\n");
else
printf("i is greater yhan 15");
else{
if(i==20)
//nested-if statement
//will only be executed if statement above
C PROGRAM
24AFECE156
//is true
if(i<22)
printf("i is smaller than 22 too\n");
else
printf("i is greter than 25");
return 0;
o\p:
I is smaller than 15
I is smaller than 12 too
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int var=2;
switch(var){
case 1:
printf("case 1 is executed");
break;
case 2:
printf("case 2 is executed");
break;
return 0;
o\p:
case 2 is executed
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=0;
for(i=1;i<=10;i++)
printf("hello world\n");
return 0;
o\p:
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=2;
while(i<10)
printf("hello world");
i++;
return 0;
o\p:
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i=2;
do{
printf("hello world");
i++;
while(i<1);
return 0;
o\p:
hello world
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i;
for(i=1;i<=10;i++){
if(i==6){
break;
printf("%d",i);
printf("loop exited.\n");
return 0;
o\p:
1 2 3 4 5 loop excited
C PROGRAM
24AFECE156
#include<stdio.h>
int main()
int i;
for(i=0;i<5;i++){
if(i==2){
printf("skipping itaration %d\n",i);
continue;
printf("executing iteration %d\n",i);
return 0;
O\p:
Executing iteration 0
Executing iteration 2
Executing iteration 3
Executing iteration 4
Executing iteration 5
C PROGRAM
24AFECE156
#include<stdio.h>
void checkevenornot(int num)
if(num%2==0)
goto even;
else
goto odd;
even:
printf("%d is even",num);
return;
odd:
printf("%d is odd",num);
int main()
int num=26;
checkevenornot(num);
return 0;
} o\p: 26 is even