Access Millions of academic & study documents

C3 conditions loops

Content type
User Generated
Showing Page:
1/27

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/27

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/27

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 27 pages?
Access Now
Unformatted Attachment Preview
C Programming DECISION CONTROL STRUCTURE Conditional Statements IF Statements If statements in C is used to control the program flow based on some condition, it's used to execute some statement code block if the expression is evaluated to true. Otherwise, it will get skipped. This is the simplest way to modify the control flow of the program. There are four different types of if statement in C. These are: Simple if Statement if-else Statement Nested if-else Statement else-if Ladder The basic format of if statement is: 'Statement n' can be a statement or a set of statements, and if the test expression is evaluated to true, the statement block will get executed, or it will get skipped. C Code : #include main() { int a = 15, b = 20; if (b > a) { printf("b is greater"); } } IF - ELSE STATEMENT If else statements in C is also used to control the program flow based on some condition, only the difference is: it's used to execute some statement code block if the expression is evaluated to true, otherwise executes else statement code block. SYNTAX : if(test_expression) { //execute your code } else { //execute your code } C Code : #include main() { int a, b; printf("Please enter the value for a:"); scanf("%d", &a); printf("\nPlease the value for b:"); scanf("%d", &b); if (a > b) { printf("\n a is greater"); } else { printf("\n b is greater"); }} Nested if else statements it means you can use conditional statements inside another conditional statement ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4