Sie sind auf Seite 1von 3

//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: ?

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

//To print bigger of two input numbers


#include<stdio.h>
void main()
{
int a,b;
printf("\nEnter a");
scanf("%d",&a);
printf("\nEnter b");
scanf("%d",&b);
if(a>b)
{
printf("\na is bigger=%d",a);
}
else
{
printf("\nb is bigger=%d",b);
}
}

output: ?

//To print square of bigger of two input numbers


#include<stdio.h>
void main()
{
int a,b;
printf("\nEnter a");
scanf("%d",&a);
printf("\nEnter b");
scanf("%d",&b);
if(a>b)
{
printf("\nSquare of a=%d",a*a);
}
else
{
printf("\nSquare of b=%d",b*b);
}
}

output: ?

#include<stdio.h>
void main()
{
int n,ch;
printf("\n1- to square");
printf("\n2- to cube");
printf("\nEnter a number");
scanf("%d",&n);
printf("\nEnter your choice");
scanf("%d",&ch);
if(ch==1)
{
printf("\nSquare of n=%d",n*n);
}
else
{
printf("\nCube of n=%d",n*n*n);
}
}

output: ?

Das könnte Ihnen auch gefallen