Search
Log in
Latest topics
Statistics
We have 30 registered usersThe newest registered user is deigavr
Our users have posted a total of 191 messages in 126 subjects
Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest None
Most users ever online was 125 on Wed Apr 07, 2021 9:18 am
6th program
Page 1 of 1
6th program
Lab 06
Objective
Study the function of While Loop.
Theory
“A while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition.”
The while construct consists of a block of code and a condition, the condition is evaluated first, if the condition is true the code within the block is then executed. This repeats until the condition becomes false. Because while loops check the condition before the block is executed, the control structure is often also known as a pre-test loop. Compare with the do while loop, which tests the condition after the loop has executed.
1. Write a program that asks the user to input a number greater than 50. If the user inputs a number smaller than 50, the program will end. Otherwise, the program will ask the user again to input a number greater than 50.
Coding
#include<stdio.h>
void main(void)
{
int m;
printf("\nENTER NUMBER GREATER THAN 50\n");
scanf("%d",&m);
while(m>50)
{
printf("\nENTER NUMBER GTREATER 50\n");
scanf("%d",&m);
}
}
Objective
Study the function of While Loop.
Theory
“A while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition.”
The while construct consists of a block of code and a condition, the condition is evaluated first, if the condition is true the code within the block is then executed. This repeats until the condition becomes false. Because while loops check the condition before the block is executed, the control structure is often also known as a pre-test loop. Compare with the do while loop, which tests the condition after the loop has executed.
1. Write a program that asks the user to input a number greater than 50. If the user inputs a number smaller than 50, the program will end. Otherwise, the program will ask the user again to input a number greater than 50.
Coding
#include<stdio.h>
void main(void)
{
int m;
printf("\nENTER NUMBER GREATER THAN 50\n");
scanf("%d",&m);
while(m>50)
{
printf("\nENTER NUMBER GTREATER 50\n");
scanf("%d",&m);
}
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Aug 01, 2011 11:44 pm by Guest
» Netbook Brands
Mon Aug 01, 2011 5:39 am by Guest
» backlinks checker backlink service
Sun Jul 31, 2011 8:56 am by Guest
» how to buy facebook fans f4
Sat Jul 30, 2011 2:34 pm by Guest
» Alle bijzondere dingen in de zaanstreek
Sat Jul 30, 2011 8:11 am by Guest
» HERE YOU CAN POST ALL WEBSITE LINKS...
Wed Aug 26, 2009 2:16 pm by onesimpletech
» cool web site for all must check it
Mon Jul 06, 2009 2:32 pm by Snopy Cobra
» poetry spirit
Mon Jul 06, 2009 2:31 pm by Snopy Cobra
» best to learn VC++
Sun May 10, 2009 3:22 pm by Guest