if_else Statement

The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the C else statement. We can use the else statement with if statement to execute a block of code when the condition is false. 
Syntax:

if (condition)

{

    // Executes this block if

    // condition is true

}

else

{

    // Executes this block if

    // condition is false

}

Flowchart: 
 

if-else-statement

1.Write a program to check if character is vowel or consonant.

#include<stdio.h>

void main()

{

    char ch;

    printf("Enter the character=");

    scanf("%c",&ch);

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

    {

        printf("The Entered Character is vowel");

    }

    else

    {

        printf("The Entered character is Consonent");

    }

}

Output: