Posts

Showing posts with the label else if ladder

GTU PPS Program - 12

Image
12. Write a program to read marks from keyboard and your program should display equivalent grade according to following table(if else ladder) Marks Grade 100 - 80 Distinction 79 - 60 First Class 59 - 40 Second Class < 40 Fail. #include<stdio.h> #include<conio.h> int main() { int m; printf("\nEnter your marks : "); scanf("%d",&m); if(m>=80&& m<=100) printf("\nDistinction"); else if(m<=79 && m>=60) printf("\nFirst Class"); else if(m<=59 && m>=40) printf("\nSecond class"); else if(m<40) printf("\nFail"); else printf("\nEnter correct marks"); getch(); return 0; } Sample output Previous Program Next Program

GTU PPS Program - 11

Image
11. Write a C program to check whether the entered character is capital, small letter, digit or any special character. #include<stdio.h> #include<conio.h> int main() { char ch; printf("\nPress any key : "); ch=getchar(); if(ch>='A' && ch<='Z') printf("\nentered character is capital letter"); else if(ch>='a'&& ch<='z') printf("\nEntered character is small letter"); else if(ch>='0'&& ch<='9') printf("\nEntered character is digit"); else printf("\nEntered character is special character"); getch(); return 0; } Sample output Previous Program Next Program

GTU PPS Program - 8

Image
8. Write a C program to find that the accepted number is Negative, or Positive or Zero. #include<stdio.h> #include<conio.h> int main() { int num; printf("\nEnter any number : "); scanf("%d",&num); if(num==0) printf("\nyou entered Zero"); else if(num>0) printf("\nEntered number is Positive"); else if(num<0) printf("\nEntered number is Negative"); else printf("\n Enter valid number"); getch(); return 0; } Sample output Previous Program Next Program

YouTube