100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Summary

Summary c programming statements

Rating
-
Sold
-
Pages
7
Uploaded on
18-01-2026
Written in
2025/2026

This document contains c programming statements with detailed information










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
January 18, 2026
Number of pages
7
Written in
2025/2026
Type
Summary

Content preview

UNIT-2 STATEMENTS
A statement is a part of your program that can be executed. That is, a statement specifies an action. Statements
generally contain expressions and end with a semicolon.
Statements that are written individually are called Single/Simple statements. Statements that are written as a
block are called Block/Compound statements. A block begins with an open brace { and ends with a closing
brace }.
C categorizes statements into these groups:
 Selection / Branch / Decision making / Conditional statements
 Loop/ Iteration/ Repetitive statements
 Jump / Control transfer statements
 Expression Statements
 Block statements/ compound statements
SELECTION STATEMENTS:
A selection statement checks the given condition and decides the execution of statements after the success or
failure of the condition. C supports two selection control statements if and switch.
1. If statement: The if statement is a decision making statement that allows the computer to evaluate an
expression (condition) first and depending on the result of the condition i.e. true or false, it transfers the control
to a particular statement.
The if statement has the following forms
a) Simple if Statement
b) if...else Statement
c) Nested if Statement
d) if..else Ladder Statement
Simple if Statement
The simple if statement contains only one condition, if the condition is true, it will execute the statements that
are present between opening and closing braces. Otherwise it will not execute those statements.
Syntax: Example:
if(condition) /* A program to check whether a number is Less than 100 or not */
Single-statement #include<stdio.h>
OR #include<conio.h>
if(condition) void main()
{ {
Statement-block int a;
} clrscr();
printf("enter an integer ");
scanf("%d",&a);
if(a<=10)
printf("%d is less than 100",a); getch();
}
if...else Statement
This statement is used to define two blocks of statements in order to execute only one block. If the condition is
true, the block of if is executed; otherwise, the block of else is executed.
Syntax: Example:
if (condition) Write a program to check whether the given number is a positive number or a
{ negative number
True Block Statements; #include<stdio.h>
------------- #include<conio.h>
} void main()
else {
{ int n;
False Block Statements; clrscr();

, ------------ printf("enter any number ");
} scanf("%d",&n);
if(n>=0)
{
printf("\n %d is a positive number",n);
}
else
{
printf("\n %d is a negative number",n);
}
getch();
}

Nested if –else Statement
When an if statement is placed in another if statement or in else statement, then it is called nested if statement.
The nested if-else is used when a series of decisions are involved. In a nested if-else, an else statement
always refers to the nearest if statement which is within the same block as the else and that is not already
associated with an else.
Syntax: Example:
if (condition) Write a program to finding greatest among three numbers
{ #include<stdio.h>
if(condition) #include<conio.h>
{ void main()
True Block Statements; {
------------- int a,b;
} clrscr();
} printf("enter any two number ");
else scanf("%d%d",&a,&b);
{ if(a>b)
False Block Statements; {
------------ if(a>c)
} printf(“ %d is greatest”,a);
else
printf(“ %d is greatest”,c);
}

else
{
if(b>c)
printf(“ %d is greatest”,b);
else
printf(“ %d is greatest”,c);
}
getch();
}

if..else Ladder Statement
The if-else ladder is used when multipath (multiple) decisions are involved.
A multipath decision is a chain of if-elses in which the statement associated with each else is an if-statement.
£5.77
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tabassumy

Also available in package deal

Thumbnail
Package deal
C programming
-
5 2026
£ 28.83 More info

Get to know the seller

Seller avatar
tabassumy
View profile
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
2 weeks
Number of followers
0
Documents
17
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions