Coding
1.
#include<stdio.h>
int main ()
{
int a,b,c;
printf("Enter the values of a & b");
scanf(" %d %d",&a,&b);
c=a+b;
printf("Ans=%d",c);
return 0;
}
2.
#include<stdio.h>
int main ()
{
int a,b,c;
printf("Enter the values of a & b");
scanf(" %d %d",&a,&b);
c=a*b;
printf("Ans=%d",c);
return 0;
}
3.
#include<stdio.h>
int main ()
{
int a,b,c;
printf("Enter the values of a & b");
scanf(" %d %d",&a,&b);
c=a/b;
printf("Ans=%d",c);
return 0;
}
4.
#include<stdio.h>
float main ()
{
float a,b,c;
printf("Enter the values of a & b");
scanf(" %f %f",&a,&b);
c=a+b;
printf("Ans=%f",c);
return 0;
}
5.
#include<stdio.h>
float main ()
{
float a,b,c;
printf("Enter the values of a & b");
scanf(" %f %f",&a,&b);
c=a*b;
printf("Ans=%f",c);
return 0;
}
6.
#include<stdio.h>
double main ()
{
double a,b,c;
printf("Enter the values of a & b");
scanf(" %lf %lf",&a,&b);
c=a*b;
printf("Ans=%lf",c);
return 0;
}
7.. are of circle integer value
#include <stdio.h>
int main() {
int r, area;
printf("Enter r ");
scanf("%d", &r);
area = 3.14 * r * r;
printf("Area of circle = %d", area);
return 0;
}
8. Area of circle in points
#include<stdio.h>
float main() {
float r, area;
printf("Enter r ");
scanf("%f", &r);
area = 3.14 * r * r;
printf("Area of circle = %f", area);
return 0;
}
9. Area of cube float
#include <stdio.h>
float main() {
float r, area;
printf("Enter r ");
scanf("%f", &r);
area =r*r*r;
printf("Area of cube = %f", area);
return 0;
}
10. Area of cylinder
#include <stdio.h>
float main() {
float r,h, area;
printf("Enter value of r and h ");
scanf("%f%f", &r,&h);
area =2*3.14*r*h + 2*3.14*r*r;
printf("Area of cylinder= %f%f", area);
return 0;
}
11. Farheinhit to celsius
#include <stdio.h>
float main()
{
float F, C;
printf("Enter temp. in F: ");
scanf("%f", &F);
C = (F- 32) * 5 / 9;
printf("Temperature in Celsius = %.f", C);
return 0;
}
12. celsisus to farheinhit
#include<stdio.h>
float main()
{
float f ,cel;
printf("Enter the value of cel");
scanf("%f",&cel);
f=1.8*cel+32;
printf("temperature in f=%f",f);
return 0;
}
13. SIMPLE INTEREST
#include <stdio.h>
int main()
{
int P,R,T,SI;
printf("enter value of P");
scanf("%d",&P);
printf("enter value of R");
scanf("%d",&R);
printf("enter value of T");
scanf("%d",&T);
SI=P*R*T/100;
printf("value of SI=%d",SI);
return 0;
}
14. Greatest number among 3 by logical
#include <stdio.h>
int main(){
int a ,b,c;
printf("Enter three digit number");
scanf("%d %d %d" ,&a, &b , &c);
if(a>=b &a>=c)
printf("greatest number is :%d",a);
else if (b>=a &b>=c)
printf("greatest number is :%d", b);
else
printf("greatest number is :%d",c);
return 0;
}
15. Greatest number among 3 by nested loop.
#include<stdio.h>
int main() {
int a,b ,c ;
printf("enter a,b,c:");
scanf( "%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
printf("a is greatest");
else
printf("c is greatest");
}
else
{
if(b>c)
printf("b is greatest");
else
printf("c is greatest ");
}
return 0;
}
16.
#include<stdio.h>
int main() {
int a,b ,c ;
printf("enter a,b,c:");
scanf( "%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
printf("a is greatest %d ",a);
else
printf("c is greatest %d",c);
}
else
{
if(b>c)
printf("b is greatest %d",b);
else
printf("c is greatest %d",c);
}
return 0;
}
17.
#include<stdio.h>
int main() {
int a,b ,c ;
printf("enter a,b,c:");
scanf( "%d%d%d",&a,&b,&c);
if (a>b&&a>c)
printf("a is greater");
if(b>a && b>c)
printf ("h is greater");
if(c>a && c>b)
printf("c s greater");
return 0;
}
18.
#include <stdio.h>
int main()
{
int a;
printf("enter any number");
scanf("%d",&a);
if(a%2==0)
printf("even");
else
printf("odd");
return 0;
}