Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int i;
6.
for (i = 0; i < 10; i++);
7.
{
8.
cout
Options:
A .  0123456789
B .  10
C .  012345678910
D .  compile time error
Answer: 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 10.
Output:
$ g++ stat2.cpp
$ a.out
10



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers