- 1
include <stdio.h> int main() { unsigned int i; int count=0; for (i=0;i<10;i--) { count++; } printf("%d ",count); return
What is output
22 Answers
+ 4
Ankit Kumar
Condition execute hi nhi hoga to loop ke bahar automatic a jayega.
+ 2
After sorting all the errors the answer will be 1
+ 1
Ankit Kumar
i = 0 ke case ke increment hoga uske baad nahi hoga kyonki i-- ki vajah se next iteration ke liye i = -1 hoga and loop execute nahi hoga to count increase nahi hoga. Count 1 hi rahne wala hai.
Mujhe lagta hai itna kafi hai samjhane ke liye.
+ 1
Remember one thing first the condition is checked then the body of the loop is executed (if condition holds true) then atlast after coming out of the body the the updation (increment or decrement) takes place
+ 1
Loop is control statment, which repeats its execution if condition is true
So program will run for only for i=0, however i--, which is a decrement operator, and now i become -1 so condition didn't satisfy then loop stop execution and went to next statment(which is displaying count )
+ 1
Nhi I ko unsigned declared kiya hai to vo negative value le hi nhi sakta to infinte loop nhi hoga .
+ 1
It's unsigned int it will execute only once ite output is 1
+ 1
Ya you are correct
0
Vo sab hata kar batyie
0
You have not closed the main function too.
0
How
0
Explain
0
Ankit Kumar
1 because after i = 0, i will be -1 because of i--
so next condition will not execute.
0
I=-1 uske bad kya hoga loop se bhar kase gayenge
0
Kya I negative value gain nhi karega or unsigned ka maximum value gain karega or loop se out ho gayega
0
At first it will check the condition and go inside the loop and atlast it will decrement the value
0
Cont to for loop ke andar hi hai to count increment kase hoga
0
Satik koi mujhe samjha sakta hai
0
Thanks
0
You have an endless loop. In your for loop, since you start with i=0 and decriment every time, i will always be less than 10