Computer Science, asked by YuvrajSingh29, 1 year ago

Can someone tell me why does the output gives 10 infinite times? #C


#include
int main()
{
int i;
while (i = 10)
{
printf("%d\n", 10);
i = i+1;
}
return 0;
}

Attachments:

Answers

Answered by aroralovely37
1
because of this condition
while (i = 10) which is assigning 10 to i every time
It should be
while (i = =10) which is comparing i with 10


arjungupta2908p98jq2: it doesen't make a difference when in a loop
Answered by arjungupta2908p98jq2
0
because you have not initialized a value to the variable i.....give it a value while initializing first...in the line:-
int i;it should be:-int i=(any number);


no other changes are required

Similar questions
Math, 1 year ago