What is the output of the program 4 points include void main
What is the output of the program (4 points)
#include<iostream.h>
void main()
{
int n=1;
cout<<endl<<\"The numbers are;\"<<endl;
do
{
cout <<n<<\"\\t\";
n++;
} while (n<=100);
cout <<endl;
}
a) Print natural numbers 0 to 99
b) Print natural numbers 1 to 99
c) Print natural numbers 0 to 100
d) Print natural numbers 1 to 100
Solution
the program will start printing from 1 hence a &c option are eliminated straight.
Now looking at the loop structure do..while loop will run till the value of n past 100
and within the loop we are incrementing the value of n by 1
hence the from 1 to 100 numbers will be printed by the program.
hence the answer is d) Print natural numbers 1 to 100
