Sample

1.write a c program add the two number ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a=12,b=2,c;
c=a+b;
printf("%d",c);
getch();
}

2. Q write a c program subtact the two number ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a=12,b=2,c;
c=a-b;
printf("%d",c);
getch();
}

3. write a c program multi the two number ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a=12,b=2,c;
c=a*b;
printf("%d",c);
getch();
}

4. write a c program divid the two number ?


#include<stdio.h>
#include<conio.h>
void main()
{
int a=12,b=2,c;
c=a/b;
printf("%d",c);
getch();
}
5. write  a c program to find the area of perimete ?


#include<stdio.h>
#include<conio.h>
void main()
{
int l=12,b=2,c;
c=2(l+b);
printf("%d",c);
getch();
}

6. write a program to find out the simple intrest ?


#include<stdio.h>
#include<conio.h>
void main()
{

float p,r,t,si;
printf("Enter the principal\n");
scanf("%f",&p);
printf("Entre the rate of intrest\n");
scanf("%f",&r);
printf("Entre the time\n");
scanf("%f",&t);
si=(p*r*t)/100;
printf("simple intrest=%f",si);
getch();
}

7. write a c program to find the area of rectangle ?

 
#include<stdio.h>
#include<conio.h>
void main()
{
int l=12,b=2,c;
c=l*b;
printf("%d",c);
getch();
}


8 writre a c program check the number is greater or less ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a=12,b=2;
if (a>b)
printf("a is greater=%d",a);
else
printf("b is  less=%d);
getch();
}

9.  write a c program check is positev or negtaive ?
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("Ente the number\n");9scanf("%d",&n);
if (n>0)
printf("positive=%d",n);
else
printf("negative=%d",n)
getch();
}

10. write a c program checck the number is leap year or not ?

#include<stdio.h>
#include<conio.h>
void main()
{
int year;
printf("Enter the year\n");
scanf("%d",&year);
if ( year%4==0)
printf("year is leap year=%d",year);
else
printf("yera is not leap year");
getch();
}

11. write a c progrgram check the case upper or lower case ?
 
#include< stdio.h>
#include<conuio.h>
void main()
{
char ch;
printf(" Ente the charecter\n");
scanf("%c",&ch);
if (ch>=65 && ch>=90)
printf(" upper case=%c",ch);
else
printf("lower case=%c",ch);
getch();
}

12.write a c program the upper case to lowe case to lower case to upper case ?

clude<conuio.h>
void main()
{
char ch;
printf(" Ente the charecter\n");
scanf("%c",&ch);
if (ch>=65 && ch>=90)
{
ch=ch+32;
printf(" lower case=%c",ch);
}
else if(ch>=97 && ch<=122)
{
ch=ch-32;
printf("lower case=%c",ch);
}
getch();
}

13. write a c program check the number is even or odd ?

#include< stdio.h>
#include<conio.h>
void main()
{

int n;
printf ("Enter the number\n");
scanf("%d",&n);
if (n%2==0)
printf("even=%d",n);
else
printf("odd=%d",n);
getch();
}

14 write a c program check the  lower case ?

#include< stdio.h>
#include<conio.h>
void main()
{
char ch;
printf(" Ente the charecter\n");
scanf("%c",&ch);
if (ch>=92 && ch>=122)
printf(" lower case=%c",ch);
else
printf("upper case=%c",ch);
getch();
}


15. write a c program check the vowel or cononate ?

#include< stdio.h>
#include<conio.h>
void main()
{
char ch;
printf("Ente the chareter \n");
scanf("%c",&ch);
if (ch=='A!!ch=='E'!!ch=='I'!!ch=='O'!!ch=='U')
printf("vowel=%c",ch);
else
printf("consonate=%c",ch);
getch();
}

16. write a c program check the charecter consonate or vowel ?

#include< stdio.h>
#include<conio.h>
void main()
{
char ch;
printf(" Ente the charecter\n");
scanf("%c",&ch);
if (ch=='b'!!ch=='c'!!ch=='d'!!ch=='f')
printf("consonate=%c",ch);
else
printf("vowel=%c",ch);
getch();
}
17. write a c program to check the number is odd ?

#include< stdio.h>
#include<conio.h>
void main()
{
int n;
printf("Enter the number ");
scanf("%d",&n);
if(n%2!=0)
printf("odd number=%d",n);
else
printf("even number=%d",n);
getch();
}

18.write a c program to print the hello ?

#include< stdio.h>
#include<conuio.h>
void main()
{
char ch;
printf(" Hello");
printf("%d",ch);
getch();
}

19. write a c program to inuput the week and print the day ?
#include< stdio.h>
#include<conio.h>
void main()
{
int week ,day;
printf("Entre the week");
scanf("%d",&week);
day=week*7;
pritf("day in week=%d",day);
getch();
}

20. write a c program to input the number the check the numberb is armstrong ?

#include< stdio.h>
#include<conio.h>
void main()
{
int a,b,c,arm,sum=o,n;
printf(" Enter the number\n");
scanf("%d",&n);
arm=n;
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/1;
n=n%1;
sum=sum+(a*a*a)+(b*b*b)+(c*c*c);
if (arm==sum)
printf("arm number=%d",sum);
else
printf("not arm number=%d",sum);
getch();
}

21. write a c program input the three digit and sum of all digit ?

#include< stdio.h>
#include<conio.h>
void main()
{
int a,b,c,n,sum=o;
printf("Enter the numebr\n");
scanf("%d",&n);
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/1;
n=n%1;
sum=sum+a+b+c;
printf("sum of all digit=%d",sum);
getch();
}

22. write a c program to input  the two no to find the greater and differenc between the two number ?

#include< stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter the two digit\n");
scanf("%d,%d"&a,&b);
if (a>b)
{
printf("a is greater=%d",a);
printf("differenc between two digit=%d",a-b);
}
else
{
printf("b is greater=%d",b);
printf("differenc between two digit=%d",b-a);
}
getch();
}

 23. write a c program to exchange the number is ?

#include< stdio.h>
#include<conio.h>
void main()
{
int a=17,b=0;
b=a;
printf("%d",b);
getch();
}
24 write a c program input the two number and exchange it ?

#include< stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter the two number");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("Enter the exchange the value");
printf("first number=%d",a);
printf( "second number="%d",b);
getch();
}
25.write a c program to iput the three digit and display it ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,n;
printf("Enter the number\n");
sacnf("%d",&n);
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/1;
n=n%1;
printf("first digit=%d",a);
printf("second digit=%d",b);
printf("third digit=%d",c);
getch();
}

26.write  a c program to input the number and check the number is revrse number ?

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c rev=0,n;
printf("Enter the number\n");
sacnf("%d",&n);
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/1;
n=n%1;
 printf("first digit=%d",a);
rev=rev+c*100+b*10+a*1;
getch();
}

27. write a c program to input the three digit sum of first and last digit and differnec bteween mid digit and second digit is positeve or negaviev ?

#include< stdio.h>
#include<coio.h> 
void main()
{
int a,b,c,sum=0,n,big=0;
printf("Enter the number\n");
scanf("%d",n);
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/10;
n=n%10;
sum=a+c;
if (sum>b)
{
big=sum-b;
printf("sum of digit=%d",big);
printf("differnce between mid digit=%d",big);
}
else
{
big=b-sum;
printf("sum of digit=%d",big);
printf("difference between mid digit=%d",big);
}
getch();
}

No comments:

Post a Comment