Hello friends how are you, today in this blog i will teach you what is if else if statement, syntax of if else if, how if else if statement works and many programs using if statement in a very simple way.
Let's start
👉Syntax

👉Example 1
#include<stdio.h> int main() { //Assigning value to the variable int x=10; if(x>5)//checking the condition { printf("x is greater than 5"); } else if(x<8)//checking the condition { printf("x is less than 8"); } else if(x==10)//checking the condition { printf("x is equal to 10"); } else { printf("No one condition is true"); } }
### output ### x is greater than 5
👉Program: Show result according to percent
/* Suppose First div >=65 Second div between 64 and 45 Third div between 44 and 33 Fail <33 */ #include<stdio.h> int main() { //variable declaration float p; //taking user input of percentage printf("Enter your percentage:"); scanf("%f",&p); if(p>=65) printf("First Division"); else if(p>=45) printf("Second Division"); else if(p>=33) printf("Third Division"); else printf("Sorry! You are fail!!!"); } /* ### Output ### Run1 Enter your percentage:85 First Division Run2 Enter your percentage:30 Sorry! You are fail!!! */
Request:-If you found this post helpful then let me know by your comment and share it with your friend.
If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all.
If you have not subscribed my website then please subscribe my website.
Try to learn something new and teach something new to other.
Thanks.
0 Comments