C Decision Making

Write a C program to check whether an alphabet is Vowel or Consonant

Description:

You need to create a C program to check whether an alphabet is Vowel or Consonant.

Conditions:

  • Create a character type variable with name of alphabet and take the value from the user.
  • You can use conditional statements.
#include <stdio.h>

int main()
{
	char alphabet;
	printf("Enter an alphabet: ");
	scanf("%c", &alphabet);

	if (alphabet == 'a' || alphabet == 'A')
	{
		printf("%c is a vowel.", alphabet);
	}
	else if (alphabet == 'e' || alphabet == 'E')
	{
		printf("%c is a vowel.", alphabet);
	}
	else if (alphabet == 'i' || alphabet == 'I')
	{
		printf("%c is a vowel.", alphabet);
	}
	else if (alphabet == 'o' || alphabet == 'O')
	{
		printf("%c is a vowel.", alphabet);
	}
	else if (alphabet == 'u' || alphabet == 'U')
	{
		printf("%c is a vowel.", alphabet);
	}
	else
	{
		printf("%c is a consonant.", alphabet);
	}
	return 0;
}
Tutorials Class - Output Window

Enter an alphabet: O
O is a vowel.

Write a C program to find the maximum number between three numbers

Description:

You need to write a C program to find the maximum number between three numbers.

Conditions:

  • Create three variables in c with name of number1, number2 and number3
  • Find out the maximum number using the nested if-else statement
#include <stdio.h>
int main()
{
    int number1, number2, number3;

    printf("Enter three numbers: ");
    scanf("%d%d%d", &number1, &number2, &number3);

    if(number1 > number2)
    {
        if(number1 > number3)
        {
            printf("Number1 is max with value of %d",number1);
        }
        else
        {
            printf("Number3 is max with value of %d",number3);
        }
    }
    else
    {
        if(number2 > number3)
        {
            printf("Number2 is max with value of %d",number2);
        }
        else
        {
            printf("Number3 is max with value of %d",number3);
        }
    }
    return 0;
}
Tutorials Class - Output Window

Enter three numbers: 10
20
30
Number3 is max with value of 30