+ 2

Int i=0,n=10; while (i<n) i++; find the loop

28th Mar 2023, 6:05 AM
Subhasmita Dash
Subhasmita Dash - avatar
47 Antworten
28th Mar 2023, 6:47 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 6
Thank you!🥰
28th Mar 2023, 7:31 AM
Subhasmita Dash
Subhasmita Dash - avatar
+ 3
Subhasmita Dash welcome 👍
28th Mar 2023, 6:48 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 3
Can you add your understandings or your difficulty in your 2nd code Subhasmita Dash? ok. let initially x = 0 , next x >= 0 true so adds x += 5 => x = 5 x >= 5 true so adds x += 2 => x = 7
28th Mar 2023, 7:30 AM
Jayakrishna 🇮🇳
+ 2
Subhasmita Dash i ki value abhi starting main 0 hai jab aapne loop chalaya hai while(i<n) iska matlab hai ki 0<10 kyuki n ki value 10 hai abhi uske baad increment ho rha hai increment ka matlab hota hai +1 kar dena like that :- i++, iska matlab i main +1 kar dena aise 0+1=1 ab i ki value 1 hai, ab phirse while loop main jayenge aur condition check karega 1<10 kyonki i ki value ab 1 hai aur n ki value 10 hi hai toh ab phirse 1 kam hai 10 se toh condition true hai now, phirse increment karega like that:- 1+1=2 ab i ki value 2 hai aur phirse while loop main check karenga aise aise chalta jayega loop tab tak jab tak i ki value 10 na ho jaye jaise hi i ki value 10 hogi like that:- 10<10 iska matlab condition false hui ab loop exit ho jayega yani stop ho jayega, I hope now you understand.
28th Mar 2023, 6:39 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
Subhasmita Dash haan, starting main i ki value 0 hogi kyoki aapne i ki value 0 le rakhi hai aur jab loop main aayega tab last main i ki value 10 ho jayegi kyonki n ki value bhi 10 hai toh last main hoga 10<10 aur while loop stop ho jayega aur last main i ki value 10 hongi.
28th Mar 2023, 6:45 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
#include <stdio.h> int main() { int i=0; int n=10; while(i<n) { printf("%d\n",i); i++; } return 0; }
30th Mar 2023, 4:04 AM
K Sharmila
K Sharmila - avatar
+ 1
Please share the code
28th Mar 2023, 6:14 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
Subhasmita Dash // intialize i variable and n variable i=0; n=10; // Now you use while loop while(i<n) // that means 0<10 it's true i++; // Now you increment the i by 1 // Like that:- 0+1= 1 //And the while loop run until the i value becomes 10 when i value is 11 that means the condition is false and the loop will exit // Hope you understand my explanation
28th Mar 2023, 6:28 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
Yes so i value is 10 Right?
28th Mar 2023, 6:42 AM
Subhasmita Dash
Subhasmita Dash - avatar
+ 1
Yes Thank you dear!
28th Mar 2023, 6:47 AM
Subhasmita Dash
Subhasmita Dash - avatar
+ 1
What would be the value of x after the following code segment completes execution? Int x =0; If (x>=0) x+=5; If (x>=5) x+=2;
28th Mar 2023, 6:56 AM
Subhasmita Dash
Subhasmita Dash - avatar
+ 1
While loop is working till i=9, and hence we get i=10.
28th Mar 2023, 10:31 AM
Simal Agrahari
Simal Agrahari - avatar
+ 1
int i=0, n=10; while(i<n) { Print i; i++; } So this while loop will run 9 times upto i value will become 9, so it's print a numbers 0 to 9 and when the value of i=10 then condition is not satisfied, So the loop will not run on that time. Loops are used to run a specific line of code for a certain times without writing that line of codes repeatedly. And here we are using a while loop it is a indefinite loop.
29th Mar 2023, 10:44 AM
Sanjay S
+ 1
29th Mar 2023, 10:56 AM
Sanjay S
0
Explain the process
28th Mar 2023, 6:21 AM
Subhasmita Dash
Subhasmita Dash - avatar
0
What would be the value of i after program segment comples execution? Int i=0,n=10; while (i<n) i++;
28th Mar 2023, 6:27 AM
Subhasmita Dash
Subhasmita Dash - avatar
0
But how dear
28th Mar 2023, 6:29 AM
Subhasmita Dash
Subhasmita Dash - avatar
0
i value 10 me execution complete hota hai na So value of i will be 10 ?
28th Mar 2023, 6:32 AM
Subhasmita Dash
Subhasmita Dash - avatar
0
Sorry
28th Mar 2023, 1:53 PM
Motivational speaker Muzammil Zafar Pathan
Motivational speaker Muzammil Zafar Pathan - avatar