- 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

7th Feb 2021, 3:48 AM
Ankit Kumar
Ankit Kumar - avatar
22 Answers
+ 4
Ankit Kumar Condition execute hi nhi hoga to loop ke bahar automatic a jayega.
7th Feb 2021, 6:19 AM
A͢J
A͢J - avatar
+ 2
After sorting all the errors the answer will be 1
7th Feb 2021, 6:16 AM
Atul [Inactive]
+ 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.
7th Feb 2021, 6:29 AM
A͢J
A͢J - avatar
+ 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
7th Feb 2021, 6:30 AM
Atul [Inactive]
+ 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 )
7th Feb 2021, 11:35 AM
Coderninja
+ 1
Nhi I ko unsigned declared kiya hai to vo negative value le hi nhi sakta to infinte loop nhi hoga .
8th Feb 2021, 6:28 AM
Ankit Kumar
Ankit Kumar - avatar
+ 1
It's unsigned int it will execute only once ite output is 1
8th Feb 2021, 6:38 AM
kiran reddy singareddy
kiran reddy singareddy - avatar
+ 1
Ya you are correct
8th Feb 2021, 6:40 AM
Ankit Kumar
Ankit Kumar - avatar
0
Vo sab hata kar batyie
7th Feb 2021, 4:02 AM
Ankit Kumar
Ankit Kumar - avatar
0
You have not closed the main function too.
7th Feb 2021, 4:21 AM
Atul [Inactive]
0
How
7th Feb 2021, 6:17 AM
Ankit Kumar
Ankit Kumar - avatar
0
Explain
7th Feb 2021, 6:17 AM
Ankit Kumar
Ankit Kumar - avatar
0
Ankit Kumar 1 because after i = 0, i will be -1 because of i-- so next condition will not execute.
7th Feb 2021, 6:17 AM
A͢J
A͢J - avatar
0
I=-1 uske bad kya hoga loop se bhar kase gayenge
7th Feb 2021, 6:18 AM
Ankit Kumar
Ankit Kumar - avatar
0
Kya I negative value gain nhi karega or unsigned ka maximum value gain karega or loop se out ho gayega
7th Feb 2021, 6:19 AM
Ankit Kumar
Ankit Kumar - avatar
0
At first it will check the condition and go inside the loop and atlast it will decrement the value
7th Feb 2021, 6:20 AM
Atul [Inactive]
0
Cont to for loop ke andar hi hai to count increment kase hoga
7th Feb 2021, 6:22 AM
Ankit Kumar
Ankit Kumar - avatar
0
Satik koi mujhe samjha sakta hai
7th Feb 2021, 6:23 AM
Ankit Kumar
Ankit Kumar - avatar
0
Thanks
7th Feb 2021, 6:30 AM
Ankit Kumar
Ankit Kumar - avatar
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
8th Feb 2021, 5:14 AM
Rae D.
Rae D. - avatar