You are on page 1of 10

Program1: Write the program to find area of

triangle.

Source Code:-

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main( )
{
int base, altitude;
float area;
printf(“Enter base, altitude”);
scanf(“%d %d”, &base, &altitude);
area=1/2*base*altitude;
printf(“area of triangle is %f”,area);
getch( );
}

Output:-
Enter base, altitude 7,8
area of triangle is 28.00

B.Sc (Eco) – 1/5081 Page 1

00 compound interest is 96. 40.r.r.00 B. printf(“simple interest is %f”. si).t 100. getch( ).t”). Source Code:- #include<stdio. scanf(“%d %d %d”. 2 simple interest is 80.t.&r.t))-p.Program2: Write the program to find simple interest and compound interest. printf(“compound interest is %f”. ci). } Output:- Enter the value of p. printf(“Enter the value of p. si=(p*r*t)/100. float si.r.&t).ci.h> #include<math. ci=(p*pow(1+r/100.h> #include<conio.&p.Sc (Eco) – 1/5081 Page 2 .h> void main( ) { int p.

} Output:- Enter any number 8 8 is not a prime number B. while(i<n) { if(n%i= =0) g = 1. printf(“Enter any number”). Source Code:- #include<stdio. g = 0. } if(g = = 1) printf(“%d is not a prime number”. n). n). else printf(“%d is a prime number”. i++.h> void main( ) { int n. &n). clrscr( ).Sc (Eco) – 1/5081 Page 3 .h> #include<conio. scanf(“%d”.h> #include<math.Program3: Write the program to check whether given number is prime or not. i=2. getch( ). i.

scanf(“%d”. printf(“Enter the number”).h> #include<conio.Program4: Write the program to check whether number is divisible by 5 and 7 or not. &num).Sc (Eco) – 1/5081 Page 4 . else printf(“Number is not divisible by 5 and 7”). clrscr( ).h> void main( ) { int num.h> #include<math. } Output:- Enter the number 23 Number is not divisible by 5 and 7 B. getch( ). if((num % 5 = = 0)&&(num % 7 = = 0)) printf(“Number is divisible by 5 and 7”). Source Code:- #include<stdio.

y = x. getch( ). } hcf = x. y”). &x. if(x>y) { while(g!=0) { g = x%y. g = 1.Sc (Eco) -1/5081 Page 5 .h> #include<conio. 20 H. scanf(“%d %d”. } hcf = y. x = g. hcf. Source Code:- #include<stdio. hcf). x = y.C.F of two numbers. } printf(“H.F is 5 B.F is %d”. } else { while(g!=0) { g = y%x. printf(“Enter the value of x.h> void main( ) { int x.h> #include<math. y = g.C.Program5: Write the program to find H. &y).C.y 15. y. } Output:- Enter the value of x.

h> #include<conio. x).053565 B. &c). d = b*b-4*a*c. &a.b. 8 Roots are imaginary 1.x .h> #include<math. c 5. scanf(“%d %d %d”.3f %. printf(“Enter a.h> void main( ) { int a.3f %. } Output:- Enter a. printf(“Roots are same %.d.y). printf(“Roots are real %. if(d = = 0) { x = -b/2*a. x. } else { if(d>0) { x = (-b+sqrt(d))/(2*a).b.Sc (Eco) – 1/5081 Page 6 . y = (-b-sqrt(d))/(2*a). b.c”). &b.Program6: Write the program to find the roots of quadratic equations. } else printf(“Roots are imaginary”). Source Code:- #include<stdio.y. } getch( ).c. float x.3f”. 7.3f”.

printf(“The tax is: %f”.1*inc.inct.Sc (Eco) – 1/5081 Page 9 . printf(“The tax is: %f”. scanf(“%f”.h> #include<conio. } else if((inc>=200000)&&(inc<300000)) { inct=0. } else if(inc>=300000) { inct=0.2*inc. printf(“Enter the income”). } Output:- Enter the income 200000 The tax is: 40000. printf(“The tax is: %f”.Program9: Write the program to find and display income tax. } getch( ).00000 B.inct). else if ((inc>=150000)&&(inc<200000)) { inct=0.inct).3*inc.inct). if(inc<150000) printf(“no tax”).&inc). Source Code:- #include<stdio.h> void main( ) { float inc.

} Output:- Enter a sentence: welcome to c The converted uppercase string is WELCOME TO C B.i<strlen(st).Program10: Write the program to enter the string using character input function and print it in uppercase. Source Code:- #include<stdio.st). for(i=0. getch( ). printf(“The converted uppercase string is %s”.Sc (Eco) – 1/5081 Page 10 .h> void main( ) { char ch.h> #include<conio. printf(“Enter a sentence:”).h> #include<ctype.i++) if(st[i]<=’a’&& st[i]>=’z’) st[i]=st[i]-32. clrscr( ). gets(st).

printf(“Greatest number is %d”. getch( ).b.Write the program to find greatest of three numbers. big). } Output:- Enter three number = 6 8 23 Greatest number is 23 B.Program7:. Source Code:- #include<stdio. &c). &a.Sc (Eco) – 1/5081 Page 7 . &b.big. if(c>big) big = c. scanf(“%d %d %d”.h> #include<math.h> #include<conio.c. if(b>big) big = b.h> void main( ) { int a. big = a. printf(“Enter three numbers = ”).

} printf(“Sum of the digit is %d”. Source Code:- #include<stdio.h> void main( ) { int r. printf(“%d”. &num). printf(“Reverse of the number”). printf(“Enter the number”).digit.Sc (Eco) – 1/5081 Page 8 . while(num>0) { digit = num%10.h> #include<math.Program8:. r = 0.h> #include<conio. digit). r = r+digit. getch( ). r). } Output:- Enter the number 289 Reverse of the number 982 Sum of the digit is 19 B.num. num = num/10.Write the program to find reverse of a number and sum of its digits. scanf(“%d”.