You are on page 1of 21

INDEX

S.
Program
No
1. Write a program to input any no. And find it is positive

,negative and zero


2

Write a program to input two no and interchange their


value using third variable

Write a program to input radius of a circle &


calculate area circumference
Write a program to input amout, rate, time and
calculate simple interest.
Write a program to input any no. And find it is a
even or odd
Write a program to input any three no. & find it is
palindrome
Write a program to input two no. Find greatest no.

4
5
6
7
8

Write a program to input three no. Find it is


armstrong or not
9 Write a program to input any year and find it is leap
year or not
10 Wap to find the grade of the student
11 Wap to find the add,subs,mult,div of the no.(switch)
12 Write a program to print the multiplication table of 2
13 Write a program to print the sum of digit 1 to 100
14 Write a program to find out the square of the no.
15 Write a program to find out the square of the no.
16 Write a program to find out fibonacci series
17 Write a program to print a-z
18 Write a program to print A-Z
19 Write a progarm to find out the prime number
20 Write a program to print the no. 1 to 10.

Sign

1.write a program to input any no. And find it is positive,negative and zero
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,i;
clrscr();
printf("enter the value of a==");
scanf("%d",&a);
if(a>0)
printf("no. is +ve");
else if(a<0)
printf("no. is -ve");
else
printf("zero");
getch();
}

OUTPUT:********************************************************
Enter the value of a == 10
No. 9 is +ve

2. WRITE A PROGRAM TO INPUT TWO NO AND INTERCHANGE THEIR


VALUE USING THIRD VARIABLE
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the value of a no.==");
scanf("%d",&a);
printf("enter the value of b==");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("a=%d\nb=%d",a,b);
getch();
}

OUTPUT:********************************************************
Enter the value of a no.==21
Enter the value of b no. ==31
a==31
b==21

3. WRITE A PROGRAM TO IPUT RADIOUS OF A CIRCLE & CALCULATE


AREA CIRCUMFERENCE
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
float area,cir,r;
clrscr();
printf("enter the radius");
scanf("%f",&r);
area=3.14*r*r;
cir=2*3.14*r;
printf("area=%f\ncir=%f",area,cir,r);
getch();
}

OUTPUT:********************************************************
Enter the radius 10
Area=314
Cir=62.8

4. WRITE A PROGRAM TO INPUT AMOUT,RATE,TIME AND CALCULATE


SIMPLE INTEREST.
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,t;
float si;
clrscr();
printf("enter the value of p==");
scanf("%d",&p);
printf("enter the value of r==");
scanf("%d",&r);
printf("enter the value of t==");
scanf("%d",&t);
si=(p*r*t)/100;
printf("si==%f",si);
getch();
}

OUTPUT:********************************************************
Enter the value of p== 1000
Enter the value f r==10
Enter the value of t ==10
Si==1000

5. WRITE A PROGRAM TO INPUT ANY NO. AND FIND IT IS A EVEN OR


ODD
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a==");
scanf("%d",&a);
if(a%2==0)
printf("even");
else
printf("odd");
getch();
}

OUTPUT:********************************************************
Enter the value of a==5
Odd
Enter the value of a== 6
even

6. WRITE A PROGRAM TO INPUT ANY THREE NO. & FIND IT IS


PALINDROME
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f;
clrscr();
printf("enter the value of a==");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=b*100+d*10+e*1;
if(a==f)
printf("palindrome");
else
printf("not palindrome");
getch();
}

7. WRITE A PROGRAM TO INPUT TWO NO. FIND GREATEST NO.


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a==");
scanf("%d",&a);
printf("enter the value of b==");
scanf("%d",&b);
if(a>b)
printf("a is greatest");
else
printf("b is greatest");
getch();
}

OUTPUT:********************************************************
Enter the value of a==12
Enter the value of b==15
B is greater

8. WRITE A PROGRAM TO INPUT THREE NO. FIND IT IS ARMSTRONG


OR NOT
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f;
clrscr();
printf("enter the values a==");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=b*b*b+d*d*d+e*e*e;
if(f==a)
printf("armstrong");
else
printf("not armstrong");
getch();
}

OUTPUT:********************************************************
Enter the values of a==153
armstrong

9. WRITE A PROGRAM TO INPUT ANY YEAR AND FIND IT IS LEAP YEAR


OR NOT
********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("enter any year value");
scanf("%d",&a);
if(a%4==0)
printf("this is leap year");
else
printf("this is not leap year");
getch();
}

OUTPUT:********************************************************
Enter any year value 2012
This is leap year

10. WAP TO FIND THE GRADE OF THE STUDENT


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int m1,m2,m3,m4,m5;
float total,per;
clrscr();
printf("enter the marks of five subject ==");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
total=(m1+m2+m3+m4+m5);
printf("total=%f",total);
per=total/5;
printf("per=%f",per);
if(per>75)
printf("honours");
else
if(per>60)
printf("first");
else
if(per>45)
printf("second");
else
printf("fail");
getch();
}

OUTPUT:********************************************************
Enter the marks of five subject=
65
63
64
66
64
first

11. WAP TO FIND THE ADD,SUBS,MULT,DIV OF THE NO.(SWITCH)


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,ch;
clrscr();
printf("enter the two no.==");
scanf("%d%d",&a,&b);
printf("the choice");
scanf("%d",&ch);
printf("enter the choice");
scanf("\n add\n sub\n mul\n div \n exit");
switch(ch)
{
case 1:
c=a+b;
printf("the sum of=%d",c);
break;
case 2:
c=a-b;
printf("the sub of=%d",c);
break;
case 3:
c=a*b;
printf("the mul of=%d",c);
break;
case 4:
c=a/b;
printf("the div of=%d",c);
break;
case 5:
exit(0);
default:
printf("invalid choice");
}
getch();
}

12. WRITE A PROGRAM TO PRINT THE MULTIPLICATION TABLE OF 2.


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i=2;
clrscr();
while(i<=20)
{
printf("\n%d",i);
i=i+2;
}
getch();
}

OUTPUT:********************************************************
2
4
6
8
10
12
14
16
18
20

13. WRITE A PROGRAM TO PRINT THE SUM OF DIGIT 1 TO 100


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int r,n,sum=0;
clrscr();
printf("enter the no.==");
scanf("%d",&n);
while(n>0)
{
r=n%10;
n=n/10;
sum=sum+r;
printf("sum==%d",sum);
}
getch();
}

OUTPUT:********************************************************
Enter the no.==123
Sum ==6

14. WRITE A PROGRAM TO FIND OUT THE SQUARE OF THE NO.


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a,sq;
clrscr();
printf("enter the any no.");
scanf("%d",&a);
sq=a*a;
printf("square==%d",sq);
getch();
}

OUTPUT:********************************************************
Enter any number 12
Square==144

15. WRITE A PROGRAM TO CALCULATE FACTORIAL


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,n;
long fact=1;
clrscr();
printf("enter the no.==");
scanf("%d",&n);
while(i<=n)
{
fact=fact*i;
i++;
}
printf("the factorial of given number =%d",fact);
getch();
}

OUTPUT:********************************************************
Enter the no.== 5
The factorial of given number =120

16. WRITE A PROGRAM TO FIND OUT FIBONACCI SERIES


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int a=0,b=1,c,i;
clrscr();
printf("enter the a,b== ");
scanf("%d%d",&a,&b);
for(i=1;i<=10;i++)
{
c=a+b;
a=b;
b=c;
printf("%d",&c);
}
getch();
}

17. WRITE A PROGRAM TO PRINT A-Z


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("\n\n\n");
for(i=65;i<=90;i++)
printf("%c",i);
getch();
}
OUTPUT:********************************************************
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

18. WRITE A PROGRAM TO PRINT a-z


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("\n\n\n");
for(i=97;i<=122;i++)
printf("%c",i);
getch();
}

OUTPUT:********************************************************
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

19. WRITE A PROGARM TO FIND OUT THE PRIME NUMBER


*******************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,d;
clrscr();
printf("1\n2\3");
for(i=3;i<10;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
d=0;
break;
}
else
d=1;
}
if(d==1)
printf("\n%d",i);
}
getch();
}

OUTPUT:********************************************************
1
2
3
5
7

20. WRITE A PROGRAM TO PRINT THE NO. 1 TO 10.


********************************************************
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf("\n\n\n");
for(i=1;i<=10;i++)
printf("%d",i);
getch();
}

OUTPUT:********************************************************
1
2
3
4
5
6
7
8
9
10

You might also like