Set 1:Q1-Q5 Set 2:Q6-Q10 Set 3:Q11-Q15
Question:1
Write a C program to take input for a character, check and print whether the character is an alphabet or not?
Sol:
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character ");
scanf("%c",&ch);
if((ch>='A' && ch<='Z') || (ch>='a' && ch<='z'))
printf("it is an alphabet");
else
printf("it is not an alphabet");
return 0;
}
Output:
Enter any character h
it is an alphabetEnter any character d
it is an alphabetEnter any character 5
it is not an alphabet
Question:2
Write a C program to take input for a character , check and print whether the character is an upper case alphabet or not?
Sol:
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character ");
scanf("%c",&ch);
if(ch>='A' && ch<='Z')
printf("it is an upper case alphabet");
else
printf("it is not an upper case alphabet");
return 0;
}
Output:
Enter any character D
it is an upper case alphabetEnter any character e
it is not an upper case alphabet
Question:3
Write a C program to take input for a character , check and print whether the character is a lower case alphabet or not?
Sol:
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character ");
scanf("%c",&ch);
if(ch>='a' && ch<='z')
printf("it is a lower case alphabet");
else
printf("it is not a lower case alphabet");
return 0;
}
Output:
Enter any character d
it is a lower case alphabetEnter any character D
it is not a lower case alphabet
Question:4
Write a C program to take input for a character , check and print whether the character is a digit or not?
Sol:
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character ");
scanf("%c",&ch);
if(ch>='0' && ch<='9')
printf("it is a digit");
else
printf("it is not a digit");
return 0;
}
Output:
Enter any character 5
it is a digitEnter any character y
it is not a digit
Question:5
Write a C program to take input for a character check and print whether the character is a vowel or not?
Sol:
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character ");
scanf("%c",&ch);
if(ch=='A' || ch=='a' || ch=='E' || ch=='e' || ch=='I' || ch=='i' || ch=='O' || ch=='o' || ch=='U' || ch=='u' )
printf("it is a vowel");
else
printf("it is not a vowel");
return 0;
}
Output:
Enter any character k
it is not a vowelEnter any character e
it is a vowel




