Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
If-Else in Decision Statements of Programming in C
2252 Views
If-Else 
If-Else is one of decision making statement. IF block of statements executed when the if condition is true otherwise executes ELSE block of statements.
Syntax 
If (condition or expression)
{
   statements;
}
else
{
   statements;
}
Program
#include
void main(){
    //declaring a and b variables
    int num;
    //getting a and b values
    printf("Enter a number\n");
    scanf("%d",&num);
    //compare a and b
    if ((num % 2) == 0)
    printf("Even number");
    else
    printf("Odd number");
}
Output 
Enter a number
12

Even number
Next Topics
Next lessons of current book.
Decision Statements of Programming in C
Decision Statements of Programming in C
Decision Statements of Programming in C
Decision Statements of Programming in C
Looping Statements of Programming in C
Previous Topics
Previous lessons of current book.
Decision Statements of Programming in C
Input Output Functions of Programming in C
Input Output Functions of Programming in C
Input Output Functions of Programming in C
Input Output Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details