Loop Types
- Which looping process is best used when the number of iterations is known?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
for
- How many types of loops are there?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
There are four types of loop. They are the while, do while, nested, for the loop.
- What is the output of this program?
#include
using namespace std;
int main()
{
int k;
for (k = 0; k < 20; k++);
{
cout << k;
}
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
for loop with a semicolon is called as body less for loop. It is used only for incrementing the variable values. So in this program the value is incremented and printed as 20.
- What is the output of this program?
#include
using namespace std;
int main()
{
int num = 20;
for ( ; ;)
cout << num;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
There is not a condition in the for loop, So it will loop continuously.