50 C Program
50 C Program
h>
void main()
1. Program to find sum of two numbers. {
#include<stdio.h> floatc,f;
#include<conio.h> clrscr();
void main() printf(“Enter temp in centigrade: ”);
{ scanf(“%f”,&c);
inta,b,s; f=(1.8*c)+32;
clrscr(); printf(“\nTemp in Fahrenheit=%f ”,f);
printf(“Enter two no:”); getch();
scanf(“%d%d",&a,&b); }
s=a+b; Output:
printf(“\nSum=%d”,s); Enter temp in centigrade: 32
getch(); Temp in Fahrenheit=89.59998
}
Output: 5. Program to calculate sum of 5 subjects and find
Enter two no: 5 6 percentage.
Sum=11 #include<stdio.h>
#include<conio.h>
2. Program to find area and circumference of void main()
circle. {
#include<stdio.h> ints1,s2,s3,s4,s5,sum,total=500;
#include<conio.h> float per;
void main() clrscr();
{ printf(“Enter marks of 5 subjects: ”);
int r; scanf(“%d%d%d%d%d”,&s1,&s2,&s3,
float pi=3.14,area,ci; &s4,&s5);
clrscr(); sum=s1+s2+s3+s4+s5;
printf(“Enter radius of circle: ”); printf(“\nSum=%d”,sum);
scanf(“%d”,&r); per=(sum*100)/total;
area=pi*r*r; printf(“\nPercentage=%f”,per);
printf(“\nArea of circle=%f ”,area); getch();
ci=2*pi*r; }
printf(“\nCircumference=%f ”,ci); Output: Enter marks of 5 subjects:
getch(); 6065506060
} Sum=300
Output: Percentage=60.000
Enter radius of a circle: 5
6. Program to show swap of two no’s without using
Area of circle=78.000
third variable.
Circumference=31.4
#include<stdio.h>
3. Program to find the simple interest. #include<conio.h>
#include<stdio.h> void main()
#include<conio.h> {
void main() inta,b;
{ clrscr();
intp,r,t,si; printf(“\nEnter value for a &b”);
clrscr(); scanf(“%d%d”,&a,&b);
printf(“Enter principle, Rate of interest a=a+b;
& time to find simple interest:”); b=a-b;
scanf(“%d%d%d”,&p,&r,&t); a=a-b;
si=(p*r*t)/100; printf(“\nAfter swapping the value of a
printf(“\nSimpleintrest= d”,si); & b: %d &%d”,a,b);
getch(); getch();
} }
Output: Enterprinciple, Output:
rateofinterest&timetofindsimpleinterest: 500 52 Enter value for a & b: 4 5
Simple interest=50 After swapping the value of a & b: 5 4
1 2 3 4 5 6 7 8 9 1
0 0 0 0 0 0 0 0 0 0
0
1 2 3 4 5 6 7 8 9 1
1 2 3 4 5 6 7 8 9 1
0
1 2 3 4 6 7 8 9 1 1
2 4 6 8 0 2 4 6 0 2
8 0