Conditionals in C Programming, Summaries of C programming

Covers The Basic of C Programming Conditionals

Typology: Summaries

2025/2026

Available from 06/08/2026

rakib-chowdhury
rakib-chowdhury 🇧🇩

5 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Conditional Statements in C
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Conditionals in C Programming and more Summaries C programming in PDF only on Docsity!

Conditional Statements in C

_ . "Diesen ee i nt CONTENT INTRODUCTION IF CONDITION IF ELSE CONDITION NESTED IF ELSE CONDITION LADDER ELSE IF CONDITION SWITCH CASE CONDITION BREAK STATEMENT GOTO LABEL STATEMENT CONTINUE STATEMENT IF CONDITION It is conditional statement, which is used to execute a set of statement on some conditions. The condition must be of Boolean type expression. An expression, which returns only two value either TRUE or FALSE, is known as Boolean type expression. Syntax: - if (condition) Irrue { Body of if ALATA PAPAS EEE EES Sttenent jun v Figure: Flowchart of if Statement In Another Words, It Can Also Be Said As Single Blocked Conditional Statements In Which Only One Part Is Mentioned. That Is Known As TRUE Part. IF ELSE CONDITION It Is Known As Double Blocked Conditional Statements .It Means, It Has TRUE Parts As Well As FALSE Part. If The Given Condition Is True Then The True Part Is Executed Otherwise False Part Is Executed. SYNTAX; - Ie (CONDITION) Seececceecceecvecces } ELSE { } False expression ‘True y Body of if Body of else i y Statement just below if..else y Figure: Flowchart of if...else Statement NESTED IF ELSE Using Of One If Statement Within Another If Statement Is Known As Nested Of If else Statement. syntax- Ty Ce ) } { else VEE. { If (cossess-.) TH eee eee Q: -_ WAP to input two numbers and print the greatest numbers. #include #include Void main() { Int a,b; Cirscr(); printf(“Enter Two Numbers”); scanf(“%d%d" ,&a,& b); lf(a==b) { Printf(“a is equal to else If(a>b) { Printf(“a is greater’); } else { Printf(“b is greater’); } getch(); } Q: - WAP to input three number and print the greatest number. IeTude } Include else Void main() { { printf("\n c is greatest: -"); Int a,b,c; } Cirscr(); ue printf Nh sdeelhirbe number: -"); if(b>c) scanf("%d",&a); { printf("\n enter secend number : -"); printf("\n b is greatest: -"); scanf("%d",&b); } printf("\n enter third number : -"); else scanf("%d",&c); { if(a>b) printf("\n c is greatest: -"); { } if(a>c) getch(); { } printf("\n a is greatest: -"); Default section: - It is optional section, which is generally used for error handling. It means by using this section we can displays error messages. In case of wrong choice entry or out of range choice. It is automatically executed when any user enters wrong choice. GOTO LABELCONDITION This statement is used to send the control from one position fo any desired position within a program. Since program is executed from top to bottom statement by statement. So if we want to execute certain part of program directly, then we can use this statement to do the same work. Label: - May Be Any User Defined Name Or Identifiers. It Is Just Like A Variable But Not A Variable. It Should Not Be Declared As Variables By Any Data Type. Label Must Be Indicated At That Place Where We Want To Send The Control And It Must Be Followed By Colon () Sign. When It Is Directly Used In A Program Then It Just Works As Infinite Loop. So It Must Be Used On Some Condition.