Posts
Showing posts from February, 2018
Program to print Pyramid of stars:
- Get link
- X
- Other Apps
#include<stdio.h> void main() { int i,j; j=1; while(j<=6) { i=1; //******* while(i<=7) //******* { //******* printf("*"); //******* i=i+1; } printf("\n"); j=j+1; } printf("\n Different Pyramid\n"); j=1; while(j<=6) { i=1; while(i<=j) { printf("*"); i=i+1; } printf("\n"); j=j+1; } printf("\n Different Pyramid\n"); j=6; while(j>=1) { i=1; while(i<=j) { printf("*"); i=i+1; } printf("\n"); j=j-1; } } Output:
Program to find whether a character is Alphabet, Digit or Special Character
- Get link
- X
- Other Apps
#include<stdio.h> void main() { char ch; printf("\nEnter the Character:"); scanf("%c",&ch); if(ch>=65 && ch<=90 ||ch>=97 && ch<=122) printf("\nEntered character is Alphabet"); else if(ch>=48 && ch<=57) printf("\nEntered character %c is Digit",ch); else if(ch>=123 && ch<=127 ||ch>=91 && ch<=96 || ch>=32 && ch<=47|| ch>=58 && ch<=64) printf("\nEntered character %c is Special Character",ch); else printf("\nEntered character %c is Non Priantable Character",ch); }
program to find entered character is vowel or consonent with switch case
- Get link
- X
- Other Apps
#include<stdio.h> #include<stdlib.h> void main() { char ch; printf("\nEnter any Character"); scanf("%c",&ch); switch(ch) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'a': case 'e': case 'i': case 'o': case 'u':printf("\nEntered character %c is vowel",ch); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0':printf("\nEntered character %c is a Digit",ch); break; default:printf("Entered character is not a vowel and digit"); } }
program to find character is vowel of digit
- Get link
- X
- Other Apps
#include<stdio.h> #include<stdlib.h> void main() { char ch; printf("\nEnter any Character"); scanf("%c",&ch); if(ch=='A' || ch=='E'|| ch=='I'|| ch=='O'|| ch=='U'|| ch=='a'|| ch=='e'|| ch=='i'|| ch=='o'|| ch=='u') printf("\nEntered character %c is vowel",ch); else if(ch=='1'|| ch=='2'|| ch=='3'|| ch=='4'|| ch=='5'|| ch=='6'|| ch=='7'|| ch=='8'|| ch=='9'|| ch=='0') printf("\nEntered character %c is a Digit",ch); else printf("Entered character is now a vowel and digit"); }
Menu Driven program with switch case statement
- Get link
- X
- Other Apps
#include<stdio.h> #include<stdlib.h> void main() { int choice,qty=0,amt=0; float ta; printf("\nMenu Card:"); printf("\n1.Pavbhaji @50"); printf("\n2.Pizza @100"); printf("\n3.Burger @45"); printf("\nEnter Your Choice:"); scanf("%d",&choice); if(choice==1) { printf("\nEnter Quantity ofPavbhaji"); scanf("%d",&qty); amt=(qty*50); } else if(choice==2) { printf("\nEnter Quantity of Pizza:"); scanf("%d",&qty); amt=(qty*100); } else if(choice==3) { printf("\nEnter Quantity of Burger:"); scanf("%d",&qty); amt=(qty*45); } else { printf("\nYour Choice is not available here"); //exit(0); } ta=amt+.18*amt; printf("\nTotal order amount is:%f",ta); }
Menu Driven Program with if else
- Get link
- X
- Other Apps
#include<stdio.h> #include<stdlib.h> void main() { int choice,qty=0,amt=0; float ta; printf("\nMenu Card:"); printf("\n1.Pavbhaji @50"); printf("\n2.Pizza @100"); printf("\n3.Burger @45"); printf("\nEnter Your Choice:"); scanf("%d",&choice); if(choice==1) { printf("\nEnter Quantity ofPavbhaji"); scanf("%d",&qty); amt=(qty*50); } else if(choice==2) { printf("\nEnter Quantity of Pizza:"); scanf("%d",&qty); amt=(qty*100); } else if(choice==3) { printf("\nEnter Quantity of Burger:"); scanf("%d",&qty); amt=(qty*45); } else { printf("\nYour Choice is not available here"); //exit(0); } ta=amt+.18*amt; printf("\nTotal order amount is:%f",ta); }
Program for Leap year
- Get link
- X
- Other Apps
#include<stdio.h>' void main() { int year; printf("\nEnter the year:"); scanf("%d",&year); if(year%4==0) { if(year%100==0) { if(year%400==0) printf("\n Year %d is a Leap year",year); else printf("\n Year %d is Not a Leap year",year); } else printf("\n Year %d is a Leap year",year); } else printf("\n Year %d is Not a Leap year",year); }
Program to find Grade of student
- Get link
- X
- Other Apps
#include<stdio.h> void main() { int Sum,Hin,Eng,Math,Science,Sst; float per; printf("\nEnter Marks Hindi "); scanf("%d",&Hin); printf("\nEnter Marks English"); scanf("%d",&Eng); printf("\nEnter Marks Maths"); scanf("%d",&Math); printf("\nEnter Marks Science"); scanf("%d",&Science); printf("\nEnter Marks Social Science"); scanf("%d",&Sst); Sum=(Hin+Eng+Math+Science+Sst); per=(float)Sum/500*100; printf("\nPercentage :%f",per); if(per>=90) printf("\n Grade A"); else if(per>=80) printf("\n Grade B"); else if(per>=70) printf("\n Grade C"); else if (per>=60) printf("\n Grade D"); else if (per>=40) printf("\n Grade E"); else printf("\n Fail"); }