Sei sulla pagina 1di 2

//To add two given numbers

#include<stdio.h>
void main()
{
int a=10,b=20,c=0;
c=a+b;
printf("\nc=%d",c);
}

output: ?

//To add two given fractional numbers


#include<stdio.h>
void main()
{
float a=10.5,b=20.3,c=0;
c=a+b;
printf("\nc=%f",c);
}

output: ?

//To find the average of three given numbers


#include<stdio.h>
void main()
{
int a=15,b=22,c=34;
float avg=0;
avg=(a+b+c)/3;
printf("\nAverage=%f",avg);
}

output: ?

//To find the area and perimeter of a rectangle


#include<stdio.h>
void main()
{
int l=10,b=20,area=0,peri=0;
area=a*b;
peri=2*(l+b);
printf("\nArea=%d",area);
printf("\nPerimeter=%d",peri);
}

output: ?

//To find the area and perimeter of a circle


#include<stdio.h>
void main()
{
int r=5;
float area=0,peri=0,pi=3.14;
area=pi*r*r;
peri=2*pi*r;
printf("\nArea=%f",area);
printf("\nPerimeter=%f",peri);
}
output: ?

Average of three float values?

//To find the total and per for three subjects marks
#include<stdio.h>
void main()
{
int m1=95,m2=89,m3=92,tot=0;
float p=0;
tot=m1+m2+m3;
p=tot/3;
printf("\nTotal=%d",tot);
printf("\nPer=%f",p);
}

output: ?

//To add two input numbers


#include<stdio.h>
void main()
{
int a,b,c=0;
printf("\nEnter a");
scanf("%d",&a);
printf("\nEnter b");
scanf("%d",&b);
c=a+b;
printf("\nc=%d",c);
}

output: ?

Potrebbero piacerti anche