top of page
Writer's pictureRosario Riley

What are Loops used for in Programming

In programming language, a loop is a sequence of instruction s that is used repeated until a certain condition is execute in a program. Generally this type of process is done, as getting an item of data and changing it, and then some condition is checked.




Let's consider the below example a situation where you want to print Welcome to Programming! five times.

#include <stdio.h>

void main()

{

printf( "Welcome to Programming!\n");

printf( "Welcome to Programming!\n");

printf( "Welcome to Programming!\n");

printf( "Welcome to Programming!\n");

printf( "Welcome to Programming!\n");

}

Output:

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

Now do same example with loop

#include <stdio.h>

void main()

{

int i = 0;

while ( i < 5 )

{

printf( "Welcome to Programming!\n");

i = i + 1;

}

}

Output:

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

Welcome to Programming!

The above mentioned program will use of a while loop, which is used to execute programming statements enclosed within this type of brackets {....}. Here, the computer system first checks whether the given condition is matched or not, i.e., variable "i" is less than 5 or not and if it finds the condition is true, then the loop body is entered to execute the given statements as above mentioned.

C contains following topics at TCCI

Introduction to C, Basic Syntax, Token, Data Types and Variables, Constants, Literals, Storage class, Operators, Loop Controls, For Loop, While Loop, Do-While Loop, Decision Making, Arrays, String, Function, Pointer, Structure, Union, Type Casting, Recursion, Files, Command Line Argument.

Course Duration: Daily/2 Days/3 Days/4 Days

Class Mode: Theory With Practical

Learn Training: At student’s Convenience

For More Information:

Call us @ +91 9825618292

Visit us @ http://tccicomputercoaching.com


Recent Posts

See All

Comments


bottom of page