Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Samenvatting

Summary c programming statements

Beoordeling
-
Verkocht
-
Pagina's
7
Geüpload op
18-01-2026
Geschreven in
2025/2026

This document contains c programming statements with detailed information

Instelling
Vak

Voorbeeld van de inhoud

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.

Geschreven voor

Instelling
Studie
Onbekend
Vak

Documentinformatie

Geüpload op
18 januari 2026
Aantal pagina's
7
Geschreven in
2025/2026
Type
SAMENVATTING

Onderwerpen

$7.66
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kan je een ander document kiezen. Je kan het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
tabassumy

Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
tabassumy
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
2 maanden
Aantal volgers
0
Documenten
17
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen