FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
1.6k views
in Tutorial & Interview questions by Goeduhub's Expert (9.3k points)

1 Answer

0 like 0 dislike
by Goeduhub's Expert (9.3k 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;

}

 

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

0 like 0 dislike
1 answer 505 views
0 like 0 dislike
1 answer 630 views
0 like 0 dislike
1 answer 502 views
0 like 0 dislike
0 answers 325 views

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...