Control Structures in C Programming

as the name suggests the “Control Structure in C Programming” enables us to specify the order in which the various instruction in a program are to be executed by the computer. in other word the control instructions determine the flow of control in a program. they are:

Sequence: it is also known as a linear statement where control flows from top to bottom.

Decision (Selection): it also known as branching create using a switch, if, if… else, nested if.. else, ladders of if.. else or if.. else.. in…. else etc.

Looping: it is also known as looping created using for, while, do.. while

Jump: it created using goto, break, continue.

Sequence Control Structures in C Programming

In a sequential statement, program control flows top to bottom. program statements are executed one after another in a sequence (i.e. statement 3 will be executed only after statement 2 is executed). it is the simplest type of control structure. it doesn’t contain any conditions and looping statements.

syntax:

statement 1;
statement 2;
.
.
.
statement n;

Example:

// 1. WAP to convert kilometer into meters:
#include<stdio.h>
#include<conio.h>
int main()
{
int km, m;
printf("Enter the Kilometer:");
scanf("%d",&km);
m=km*1000;
printf("The length in Meter: %d",m);
return 0;
getch();
}
Control Structures in C Programming
output of above program
// A C Program to divide an integer by another integer and find the quotient and remainder

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b, quotient, remainder;
clrser();
printf("Enter two numbers A & B : ");
scanf ("%d %d", &a,&b);
quotient= a/b;
remainder = a%b;
printf("Quotient = %d", quotient);
printf("\n Remainder= %d", remainder);
return 0;
getch();
}
Control Structures in C Programming
Above program output

Next Part To be continue…..

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!