1.write a program enter the any charecter to check number is captial letter small digit or special samble ?
#include< stdio.h>
#include<conio.h>
void main()
{
char ch;
printf("Enter the chareter\n");
scanf("%c",&ch);
if(ch>=65 && ch<=90)
printf("captial letter=%c",ch);
else if(ch>=97 && ch<=122)
printf("small letter=%c",ch);
else if (ch>=48 && ch<=57)
printf("Digit=%c",ch);
else(ch>=0&& ch<=9)&&(ch>=123 && ch<=127)
printf("special symbol=%c",ch);
getch();
}
2. write a c program enter the number and check the grade fail and pass ?
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("Enter the number\n");
scanf("%d",&n);
if(n>=0 && n<=33)
printf("you are fail=%d\n",n);
else if(n>=33 && n<=45)
printf("you have grade D=%d\n",n);
else if(n>=45 && n<=55)
printf("you have grde C=%d\n",n);
else if(n>=55 && n<=65)
printf("you have grade B=%d\n");
else if(n>=65 && n<=75)
printf("you have grade C=%d\n",n);
else (n>=75 && n<=100)
printf("you have a grade A=%d\n);
getch();
}
3. write a c program to input the two intger and check if they are equal ?
#include< stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter the value for A and B\n");
scanf("%d"%d",&a,&b);
if(a==b)
printf("A and B are equal\n");
else
printf("A and B are not equal\n");
getch();
}
4.write a c program to input the electricty unite cgarge and calculate total electricity bill acc to the geive condition-
1. 50 unite Rs 0.5/unite
2. 100 unite Rs 0.75/unite
3. 200 unite RS 1.20/unite
an additon surplus-charge of 20% is added to the bills ?
#include<stdio.h>
#include<conio.h>
void main()
{
int unite,
float amt,total amt,surpls-charge;
printf("Entre the unite\n");
scanf("%d",&unite);
if(unite<=50)
{
amt=unite*0.50;
}
else if(unite<=100)
{
amt=25+(unite-50)*0.75;
}
else if (unite <=200)
{
amt=62.50+(unite -100)*1.20;
}
else if(unit<=250)
{
amt=182.52+(unite -200)*1.50;
}
surpls-charge=amt+0.20;
total amt=amt+surpluse-charge;
printf("total amt=%2f",total amt);
getch();
}
5.write a c program to input the electricty unite cgarge and calculate total electricity bill acc to the geive condition-
For 1-100 unite=Rs 5/unit
For 100-200 unite=Rs 7/unite
For 200-300 unite=Rs 10/unite
for above 300 unite=Rs 15/unite
plus additional sur-charge 20%
#include<stdio.h>
#include<conio.h>
void main()
{
int unite,
float amt,total amt,surpls-charge;
printf("Entre the unite\n");
scanf("%d",&unite);
if(unite>=1 &&unite <=100)
{
amt=unite *5;
}
else if(unite>=100 && unite <=200)
{
amt= 500+(unite -100)*7;
}
else if(unite >=200 && unite<=300)
{
amt= 1200+(unite-200)*10;
}
else(unite>=300)
{
amt=2300+(unite-200)*15;
}
sur-charge=amt*20;
total amt=amt+sur-charge;
printf("Electricty bill=%2f",total amt);
getch();
}
5. write a c program calculate the pair of the passanger in trvael in a bus the conductor mention the pair to the passangr according to the following category ?
5km-Rs 10
5-10km,Rs20
10-30km,Rs50
30-50 Rs 100
50-80 Rs 150
80-100 Rs250
#include<stdio.h>
#include<conio.h>
void main()
{
float distance,sur-charge,amt,km;
printf("Enter the distance\n");
scanf("%f",&distance);
if (km<=5)
{
amt=km*10;
}
else if(km>=5 && km<=10)
{
amt= 50+(km-5)*20;
}
else if(km>=10 && km<=30)
{
amt= 150+(km-10)*50;
}
else if (km>=30 && km<=50)
{
amt=1150+(km-30)*100;
}
else if(km>50 && km<=80)
{
amt=3150+(km-50)*150;
}
else if(km>=80 && km<=100)
{
amt= 4500+(km-80)*250;
}
sue-charge=amt*10;
totalamt=amt+surcharge;
printf("ticket bill=Rs % 2f",totalamt);
getch();
}
6. write a c program to read the radius of circual ?
#include<stdio.h>
#include<conio.h>
void main()
{
float area r=5;
area circul=3.14*r*r;
printf("area of circle=%f",area of circul);
getch();
}
7. wtrite a c program to read the circufirence of circle ?
#include<stdio.h>
#include<conio.h>
void main()
{
float c r=2;
c=2*3.14*2;
printf("circumferece of circle=%f",c);
getch();
}
36.write a c program to read the area of triangle ?
#include<stdio.h>
#include<conio.h>
void main()
{
float area,b=3,h=6;
area=b*h/2;
printf("Area of tringle=%f",area);
getch();
}
37. write a c program to find out the surface area of cylinder?
#include<stdio.h>
#include<conio.h>
void main()
{
float c,r=3,h=2;
c=2*3.14*r*h;
printf("surface area boof cylinde=%f",c);
getch();
}
38.write a c program calulate the profit and loss ?
#include<stdio.h>
#include<conio.h>
void main()
{
float sp,cp,p,n;
printf("Enter the sp\n");
sacnf(%f",&sp);
p=sp-cp;
if(p>cp)
{
n=p-cp;
printf("profit=%f",n);
}
else if(p<cp)
{
n=cp-p;
printf("loss=%f",n);
}
else if(p==cp)
{
printf("no profit=%f",p);
}
getch();
}
39..write a c program find out the average subject like physics,chemistry,math ?
#include<stdio.h>
#include<conio.h>
void main()
{
float p=10,c=5 m=5,avg;
avg=(p+c+m)/3;
printf("average of result=%f",avg);
getch();
}
40.write a c program swappimg of two number usimg third variable method ?
#inlcude<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20,c;
printf("before swapping a=%d and b=%d\n",a,b);
c=a+b;
a=c-a;
b=c-b;
printf("After swapping a=%d and b=%d\n",a,b);
getch();
}
41 write a c program check the greater value in two number ?
#include<stdio.h>
#include<conio.h>
void main()
{
int f,s;
printf("Enter the number\n");
sanf("%d",&f);
printf("Enter the secondnnumber\n");
scanf("%d",&s);
if(f>s)
{
printf("first no is grater=%d",f);
"
if(f<s)
{
printf("second no is greate=%d",f);
}
if(f==s)
{
printf("both are equal=d",f);
}
getch();
}
42.write a c program check the greater value in three numbe ?
#inlude<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the first no\n");
scanf("%d",&a);
printf("Enter the second no\n");
scanf("%d",&b);
printf("Enter the third no\n");
scanf("%d",&c);
if(a>b && a>c)
{
printf("%d is greater",a);
}
if(b>a && b>c)
{
printf("%d is greater",b);
}
if(c>a && c>b)
{
printf("%d is greater",c);
}
getch();
}
43. write a c program show result according to percent ?
#include<stdio.h>
#include<conio.h>
void main()
{
float p;
printf("Ener the number\n");
scanf("%f",&p);
if(p<100 && p>60)
{
printf("first division=%d",p);
}
else if (p<60 && p>=45)
{
printf("second=%d",p);
}
else if(p<45 && p>=33)
{
printf("third number=%d",p);
}
else if(p<33)
{
printf("fail=%d",p);
}
getch();
}
44.wtrite a c program to find the voting age ?
#include<stdio.h>
#include<conio.h>
void main()
{
int age;
printf("Enter the your age\n");
scanf("%d",&age);
if(age>=18)
printf("you are eligible for voting=%d",age);
else
printf("yor are not eligible for voting=%d",age);
getch();
}
45.write a c program to input the number and check the number is pollydram or not ?
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c rev=0,n, sum=0,orignal;
printf("Enter the number\n");
sacnf("%d",&n);
orignal=n;
a=n/100;
n=n%100;
b=n/10;
n=n%10;
c=n/1;
n=n%1;
printf("first digit=%d",a);
sum=rev+c*100+b*10+a*1;
if(sum==orignal)
printf("polly=%d\n");
else
printf("not polly=%d\n");
getch();
}
46.write a c program to input the monthe find the year ?
#include<stdio.h>
#include<conio.h>
{
int year,month;
printf("enter the month\n");
sacnf("%d",&month);
year=month*12;
printf("month in year=%d\n",year);
getch();
}
Lets learn contain the c & c++ programs basic,if else,switch ,loops (while ,do while,for) fuctions,strings ,arrays, and file handling etc
Conditional
Subscribe to:
Comments (Atom)
No comments:
Post a Comment