Decision Making
In here you can learn different types of selection statements to select some actions. For examples if, if…else , nested if , while , switch. You can learn how to convert a given value to a specific data type and to use operators to increment, decrements and assignment.

Selection Control Structure : if selection statement
This is the first Selection Control Structure. if statement performs an action if a condition is true. For example,

Try to do this one,
Write a program in C to read two integer numbers from the keyboard and check the numbers are equal.
Selection Control Structure : if … else Selection Statement
Another Selection Control Structure is if…else statement. This statement use to check the condition is true or false.

Try to do this one,
Write a program in C to read two integer numbers from the keyboard and display the highest number.
Selection Control Structure : Nested if … else statement
This statement handle multiple cases by placing if … else statements. There are two ways to code it. For example,

You can code like this also,

Switch Statement in c programming
This statement is an alternative to the nested if… else statement. In here we consists of a series of case labels. So multiple statements can be executed for a given condition and we use break statement to terminate the execution of a condition. For example,

Cast operator in c programming
Cast operators force the conversation of a value to a specific type. It means you can convert one data type to another data type. For an example, you want to convert integer value to float,

In here you can see the total value is a integer type variable. also the size variable is a integer type variable. But the variable called average is a float type. “total / size” will give you the integer value. Because of those two variables are integer. So you can use Cast operator to solve this problem.
Conditional Operator in c programming
This is also related to if…else statement. For example,

This has 3 steps in one line. First is a condition. Then the 2nd step is the value if the condition is true. Last step is the value if the condition is false. Above statement is same as,
if( mark >= 60 ){
printf(“passed”);
}else{
printf(“Failed”);
}
So if you want to code a program with minimum lines, Do this operator.
Assignment Operators in c programming
For example,
- k = ++n //increment n = n + 1; then k = n;
- k = n++ //increment k = n ; then n = n + 1;
- k = –n //decrements n = n – 1; then k = n;
- k = n– //decrements k = n; then n = n – 1;
Do the following quiz (no = 10 and x = 5 )
- no -= 4 ;
- printf( “%d, %d”, x++, no–) ;
- x–
- no+++
Logical Operators in c programming
- for the logical operation “AND” we use “&&” operator. This operator evaluates if the two conditions are true. For example, if( (avg > 75) && ( age > 18 ) )
- for the logical operation “OR” we use “||” operator. This one evaluates if a one condition is true. For example, if( (avg > 75) || ( avg > 65 ) )
- for the logical operation “NOT” we use “!”. For example, if( count != 10 )
Do the following quiz ( no = 5 , size = 9 ),
- no == 3 && size == 9
- no >1 && size > 5
- !( size == 1 )
- no ==5 && size < 7
So this is the end of this article. I f you have any problems Contact Us. You can do coding in repl.it
Thank you. Make sure to leave a comment.
There are more articles from BuildITMasters. Follow the below link to refer.
Other articles from different categories.
- Android Studio Articles – https://builditmasters.com/category/android-studio/
- Android Studio Firebase Tutorial – https://builditmasters.com/category/android-studio-firebase-tutorial/
- C Programming – https://builditmasters.com/category/programming/
- Flutter – https://builditmasters.com/category/flutter/
- GitHub Tutorials – https://builditmasters.com/category/github/
- Java Programming – https://builditmasters.com/category/java-programming/
- MERN / MEVN Stacks – https://builditmasters.com/category/mern_mevn_stacks/
- Tech News – https://builditmasters.com/category/tech-news/
- Theory Lessons – https://builditmasters.com/category/theory-lessons/
- Adobe Tutorials – https://builditmasters.com/category/adobe-tutorials/
- Best Website for Programming – https://builditmasters.com/category/best-website-for-programming/
- Different Programming Styles – https://builditmasters.com/category/different-programming-styles/
- Earn Money – https://builditmasters.com/category/earn-money/
- Social Word – https://builditmasters.com/category/social-world/