Write a loop to print a list of numbers starting at 64 and ending at 339. Justify your syntax.
ANSWER:
Loop to print a list of numbers starting at 64 and ending at 339.
for(i=64;i<=339;i++)
{
cout<<i;
}
We use for loop to print the list.
Syntax:
for(initialization;condition checking;increment/decrement);
{
//Statements
}
1. In initialization section we intialize i variable to 64.
2.Second step is condition checking and we check that the i is less than equal to 339.If condition true then the statement inside the body block executed else the loop gets terminated.
3.Third step is increment and we increment i with 1 until the condition is false.
Program to print a list of numbers starting at 64 and ending at 339.
Get Answers For Free
Most questions answered within 1 hours.