Programs in C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

1) PRINT "HELLO"

#include<stdio.h> #include<conio.h> main() { clrscr(); printf ("HELLO"); getch(); }

2) SUM OF TWO NUMBERS


#include<stdio.h> #include<conio.h> main() { clrscr(); int a,b,sum; printf ( ENTER THE VALUE OF a); scanf (%d,&a); printf ( ENTER THE VALUE OF b ); scanf (%d,&b); c=a+b; printf ( sum of a and b is = getch(); } %d,c);

3) SIMPLE INTEREST
#include<stdio.h> #include<conio.h> main() { clrscr(); float p,r,t; double si; printf ( enter principal amount ); scanf (%f,&p); printf ( enter rate of interest ); scanf (%f,&r); printf ( enter time); scanf (%f,&t); si=((p*r*t)/100)); printf ( simple interest = getch(); } %lf,si);

4) VOLUME OF CUBOID

#include<stdio.h> #include<conio.h> main() { clrscr(); float l,b,h; double vol; printf ( enter lenth ); scanf (%f,&l); printf ( enter width ); scanf (%f,&b); printf ( enter height); scanf (%f,&h); si=(l*b*h); printf ( volume of cuboid = getch(); } %lf,vol);

5) GIVEN NUMBER IS EVEN


#include<stdio.h> #include<conio.h> main() { clrscr(); int a; printf ( enter the number ); scanf (%d,&a); if (a%2 ==0) { Printf ( given number is even); } getch(); }

6) GIVEN NUMBER IS ODD


#include<stdio.h> #include<conio.h> main() { clrscr(); int a; printf ( enter the number ); scanf (%d,&a); if (a%2 !=0) { Printf ( given number is odd); } getch(); }

7) EVEN OR ODD
#include<stdio.h> #include<conio.h> main() { clrscr(); int a; printf ( enter the number ); scanf (%d,&a); if (a%2 !=0) { Printf ( given number is odd); } else { Printf ( given number is even); } getch(); }

8) GIVEN NUMBER IS DIVISIBLE BY 8

#include<stdio.h> #include<conio.h> main() { clrscr(); int a; printf ( enter the number ); scanf (%d,&a); if (a%8 ==0)

{ Printf ( given number is divisible by 8 odd); } else { Printf ( given number is not divisible by 8); } getch(); }

9) GIVEN NUMBER IS DIVISIBLE BYANOTHER NUMBER

#include<stdio.h> #include<conio.h> main() { clrscr(); int a,b; printf ( enter the number a ); scanf (%d,&a); printf ( enter the number b ); scanf (%d,&b); if (a%b==0) { Printf ( a is divisible by b); } else { Printf ( a is not divisible by b); } getch(); }

10) PERSON IS ABLE TO VOTE OR NOT


#include<stdio.h> #include<conio.h> main() { clrscr(); int age; printf ("enter age of person"); scanf ("%d",&age); if (age<18) { printf("person is not eligible to vote"); } else { printf ("person is able to vote"); } getch(); }

You might also like