Rédigé par des étudiants ayant réussi Disponible immédiatement après paiement Lire en ligne ou en PDF Mauvais document ? Échangez-le gratuitement 4,6 TrustPilot
logo-home
Resume

Summary c programming statements

Note
-
Vendu
-
Pages
7
Publié le
18-01-2026
Écrit en
2025/2026

This document contains c programming statements with detailed information

Établissement
Cours

Aperçu du contenu

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.

École, étude et sujet

Établissement
Cours
Inconnu
Cours

Infos sur le Document

Publié le
18 janvier 2026
Nombre de pages
7
Écrit en
2025/2026
Type
RESUME

Sujets

6,83 €
Accéder à l'intégralité du document:

Mauvais document ? Échangez-le gratuitement Dans les 14 jours suivant votre achat et avant le téléchargement, vous pouvez choisir un autre document. Vous pouvez simplement dépenser le montant à nouveau.
Rédigé par des étudiants ayant réussi
Disponible immédiatement après paiement
Lire en ligne ou en PDF

Faites connaissance avec le vendeur
Seller avatar
tabassumy

Document également disponible en groupe

Faites connaissance avec le vendeur

Seller avatar
tabassumy
S'abonner Vous devez être connecté afin de pouvoir suivre les étudiants ou les formations
Vendu
-
Membre depuis
2 mois
Nombre de followers
0
Documents
17
Dernière vente
-

0,0

0 revues

5
0
4
0
3
0
2
0
1
0

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions