Monday, 22 July 2019

While Loop in C

While loop in C


While loop is used in programs for the repeated execution in a loop until a certain condition is satisfied the loop.

Syntax:

while(test-condition)
{
//body of the loop
}

Test-condition is indicated at the top and it takes the value of the expression before processing the body of the loop.The loop statements will be executed till the condition is true.When the condition becomes false the execution will be out of the loop.

lets take an example:

A program to print a string nine times on the output screen using while loop.

String program in c

String program using while loop in c


A program to add 10 consecutive numbers starting from 1.

Consecutive number program in C

Consecutive Number program using while loop


A program to print factorial of a given number using while loop.

Factorial using while loop

Factorial program using while loop


While loop Programs in C

Lets take some more examples of while loop in c

A program to convert decimal number in to binary number.


Convert number using while loop

Convert number program using while loop

A program to input a number by user and sum of its digits.


Digit program using while loop

Program using while loop

A program to print the entered number in the reversed order.


Reverse number using while loop

Reverse number Program using while loop



No comments:

Post a Comment

Recent Post

Python Project | Banking System | Project on Banking System using python

  PYTHON PROJECT Banking System import csv import pandas as pd import matplotlib.pyplot as plt import sys import datetime found=False def ne...