to check whether a character is an alphabet, digit or special character.
Input : @
Output : This is a special character.
int grade(char x){
if(isalpha (x)>=1)
printf("Alphabet");
else if(isdigit (x)>=1)
printf("Digit");
else
printf("Special character");
return 0;
}
int main(){
char y;
printf("Enter sign: ");
scanf("%c", &y);
grade(y);
return 0;
}
Write a C program to check whether an alphabet is a vowel or consonant.
Input : k
Output : The alphabet is a consonant.
#include <stdio.h>
#include <stdlib.h>
int grade(char a){
if(a=='a')
printf("vowel");
else if(a=='e')
printf("vowel");
else if(a=='i')
printf("vowel");
else if(a=='o')
printf("vowel");
else if(a=='u')
printf("vowel");
else if(a=='A')
printf("vowel");
else if(a=='E')
printf("vowel");
else if(a=='I')
printf("vowel");
else if(a=='O')
printf("vowel");
else if(a=='U')
printf("vowel");
else
printf("Consonant");
return 0;
}
int main(){
char y;
printf("Enter sign: ");
scanf("%c", &y);
grade(y);
return 0;
}
Write a program in C to accept a grade and declare the equivalent
description :
Grade Description
E Excellent
V Very Good
G Good
A Average
F Fail
Input : Input the grade :A
Output : You have chosen : Average
#include <stdio.h>
#include <stdlib.h>
int grade(char x){
if(x=='E')
printf("Excellent");
else if(x=='V')
printf("Very Good");
else if(x=='G')
printf("Good");
else if(x=='A')
printf("Average");
else if(x=='F')
printf("Fail");
else
printf("Invalid");
return 0;
}
int main(){
char y;
printf("Enter sign: ");
scanf("%c", &y);
grade(y);
return 0;
}
12. Write a C program to read temperature in centigrade and display a suitable
message
according to temperature state below :
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot
Temp >=40 then Its Very Hot
Input : 42
Output : Its very hot.
#include <stdio.h>
#include <stdlib.h>
int grade(int x){
if(x<0)
printf("Freezing weather");
else if(x<=10)
printf("Very Cold weather");
else if(x<=20)
printf("Cold weather");
else if(x<=30)
printf("Normal");
else if(x<=40)
printf("Hot");
else if(x>=40)
printf("Very Hot");
return 0;
}
int main(){
int y;
printf("Enter tempereture: ");
scanf("%d", &y);
grade(y);
return 0;
}