Friday, 20 December 2013

Simple program of c

                        

                               Simple program of c
·       / * Program to display message on the screen */
#include<stdio.h>
 void main()
{
 printf(“Welcome to the Word of c”);
}

·        /* program to print the sum of two number */
#include<stdio.h>
 void main()
{
 int x, y, s;
 printf(“enter the two number”);
 scanf(“%d%d”,&x,&y);
 s=x+y;
 printf(“sum=%d”,s);
}
·       /* program to print the product of three number */
#include<stdio.h>
 void main()
{
 int a,b,c,p;
 printf(“enter the three number”);
 scanf(“%d%d%d”,&a,&,b,&c);
p=a*b*c;
printf(“product=%d”,p);
}

·       /* program to print area of rectangle */
#include<stdio.h>
 void main()
{
int l,b,a;
printf(“enter the length and breadth of rectangel”);
scanf(“%d%d”,&l,&b);
a=l*b;
printf(“area of rectangle is =%d”,a);
}

·       /* program to print circumference of circle */
#include<stdio.h>
 void main()
{
int r;
float c;
printf(“enter the radius of circle”);
scanf(“%d”,&r);
c=3.14*r*r;
printf(“circumference of circle is %f”,c);
}

·       /* program to interchange or swap of two number */
#include<stdio.h>
void main()
{
Int x,y,t;
printf(“enter two number”);
scanf(“%d%d”,&x,&y);
printf(“before interchange \n”);
printf(“x=%d\n y= %d”,x,y);
t=x;
x=y;
y=t;
printf(“after inter change\n”);
printf(“x=%d\n y=%d\n”x,y);
}

       






No comments:

Post a Comment