0

Please tell the output?? Ignore any syntax error

Main() { int a,b; clrscr(); a=b=1; while (a) { a=b++ <=3 Printf ("%d %d ", a,b); } Printf("\n %d %d", a+10, b+10); }

19th Oct 2019, 10:16 AM
Aarish Khanna
Aarish Khanna - avatar
9 Antworten
+ 4
SYNTAX CORRECTED: # include<stdio.h> int main() { int a,b; clrscr(); a = b = 1; while (a) { a = b++ < 3; printf("%d %d", a, b); } printf("/n %d %d", a+10, b+10); } // Output: 1 2 1 3 1 4 0 5 10 15 I think may be m wrong. I use to learn C , C++ but i left at middle and move to python.
19th Oct 2019, 10:27 AM
★«D.Connect_Zone»
★«D.Connect_Zone» - avatar
+ 1
It is correct can u explain a bit
19th Oct 2019, 10:34 AM
Aarish Khanna
Aarish Khanna - avatar
+ 1
Well, a = b = 1 // here a and b value is set to 1 while (a) // If the test expression is true, statements inside the body of while loop are executed. Then, the test expression is evaluated again. The process goes on until the test expression is evaluated to false. If the test expression is false, the loop terminates (ends). a = b++ < 3; // b++ here the value of b will increase by 1. and continues till < 3; %d - decimal format specifier I'm not good at explaining as english is a bit hard for me.
19th Oct 2019, 10:42 AM
★«D.Connect_Zone»
★«D.Connect_Zone» - avatar
+ 1
"\n" opps and there in second print statement '\n' is used so 10 15 will be printed next line.
19th Oct 2019, 10:44 AM
★«D.Connect_Zone»
★«D.Connect_Zone» - avatar
+ 1
hmm..Second print statement is outside while loop block.
19th Oct 2019, 10:52 AM
★«D.Connect_Zone»
★«D.Connect_Zone» - avatar
+ 1
Ok thnk u so much
19th Oct 2019, 10:56 AM
Aarish Khanna
Aarish Khanna - avatar
0
b should continue till < 3 but we have 4 and 5 in output also
19th Oct 2019, 10:49 AM
Aarish Khanna
Aarish Khanna - avatar
0
And how does the value of a decremented to zero from 1 in output??
19th Oct 2019, 10:52 AM
Aarish Khanna
Aarish Khanna - avatar
0
First it will complete the while loop after while the value we get it will add on a and b automatically,Simple
13th Dec 2019, 4:22 AM
Sahil Khanna
Sahil Khanna - avatar