Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
Goeduhub's Online Courses @ Udemy in Just INR 570/-
Online Training - Youtube Live Class Link
0 like 0 dislike
529 views
in Tutorial & Interview questions by Goeduhub's Expert (8.3k points)

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 360/- || For International Students- $9.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

3.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon
    More Courses

1 Answer

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

}

 

3.3k questions

7.1k answers

394 comments

4.6k users

Related questions

0 like 0 dislike
1 answer 197 views
0 like 0 dislike
1 answer 179 views
0 like 0 dislike
1 answer 150 views
0 like 0 dislike
0 answers 118 views

 Goeduhub:

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