GOEDUHUB Online Courses || Last Batch Student's Projects || COVID-19 Projects(AI-ML) || Universities  ||  Placement Preparation  Subscribe our youtube channel
+91-7976731765 Free Online Tutorials || AI || ML || NLP ||  OpenCV || Python || DBMS || OOPs || DSA || Java || Linux/Unix ||  C Programming
0 like 0 dislike
54 views
in Tutorial & Interview questions by Goeduhub's Expert (8k points)

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8k points)
 
Best answer

Program to check if the given character is a vowel or consonant

#include <stdio.h>

 int main()

{

  char ch;

  printf("Enter a character\n");

  scanf("%c", &ch);

   // Checking both lower and upper case, || is the OR operator

   if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')

    printf("%c is a vowel.\n", ch);

  else

    printf("%c isn't a vowel.\n", ch);

     return 0;

}

 C program to check whether the character is an alphabet or not

#include <stdio.h>

int main()

{

char c;

printf("Enter a character: ");

scanf("%c",&c);

if( (c>='a' && c<='z') || (c>='A' && c<='Z'))

printf("%c is an alphabet.",c);

else

printf("%c is not an alphabet.",c);

return 0;

}

 Note-In C programming, a character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself.

The ASCII value of lowercase alphabets are from 97 to 122. And, the ASCII value of uppercase alphabets are from 65 to 90.

You can write if condition like-if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))

C Program to find the ASCII value of a character.

#include <stdio.h>

int main()

{

char c;

printf("Enter a character: ");

// Reads character input from the user

scanf("%c", &c);

// %d displays the integer value of a character

// %c displays the actual character

printf("ASCII value of %c = %d", c, c);

return 0;

}

Note: In this program, user is asked to enter a character which is stored in variable c. The ASCII value of that character is stored in variable c rather than that variable itself.

When %d format string is used, 71 (ASCII value of 'G') is displayed.

When %c format string is used, 'G' itself is displayed.

C program to check whether a given character is upper case, lower case, number or special character 

 #include

int main()
{
//Fill the code
char ch;
scanf(“%c”,&ch);
if(ch >= 65 && ch <= 90)
printf(“Upper”);
else if(ch >= 97 && ch <= 122)
printf(“Lower”);
else if(ch >= 48 && ch <= 57)
printf(“Number”);
else
printf(“Symbol”);
return 0;
}

Odd or even program in C using modulus operator

#include <stdio.h>

 int main()

{

   int n;

      printf("Enter an integer\n");

   scanf("%d", &n);

   

   if (n%2 == 0)

      printf("Even\n");

   else

      printf("Odd\n");

        return 0;

}

 

Related questions

0 like 0 dislike
1 answer 11 views
0 like 0 dislike
1 answer 39 views
0 like 0 dislike
1 answer 27 views
0 like 0 dislike
0 answers 18 views
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Important Lists: List of NITsList of IITsList of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG)College ReviewsCollege Fest, Events & WorkshopsKnowledge ShareTrainees/Interns After 15-04-2020
Exams & Cutoffs: JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs || Cutoff-GATECutoff_IIT-JEECS-ScopeECE ScopeEE-Scope
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...