+ 2
How can we use a while loop by prompting the user for an integer and the system prints it 5 times only?
4 ответов
+ 5
int i = 0;
while(i < 5){
//some code
i++;
}
+ 3
Stephen Matara use input library class like Scanner, test the condition inside while would execute until the test condition is true. Finally use System output print and increment the integer by 1, from 1 to 5.
0
Initilize another integer n, then read the value of n using scanf statement.
0
Int n;
Int i;
Printf("enter value for n\n")
Scanf("%d", &n
);
While(i<n)
{ //print statement
I++;
}