how does the for loop work actually..suppose for the
following program how it ll work plz explain to me
for(i=5;i>=0;i--)
prinf(i--);
Answers were Sorted based on User's Feedback
Answer / ratan
All above answers are wrong.
Correct answer is
5
3
1.
This is because the value "i" is decremented twice (once in
the loop and second time in the printf() function).
Is This Answer Correct ? | 24 Yes | 2 No |
Answer / manju
The output for the given for loop is
5 3 1.
why because...
first the value of (i=5)>=0,so 5 is printed.After that i
value is decremented because of i-- in the printf() and
again i value is decremented as specified in for loop.
Now the value of i=3.
Again the loop will be continued untill the value of i
becomes 0.
Is This Answer Correct ? | 15 Yes | 1 No |
The correct answer is
5
3
1
because
in for loop "i--" statement is there and again in printf
statement "i--" is there.
Is This Answer Correct ? | 8 Yes | 1 No |
Answer / rima
It will give compilatiin error "warning: passing argument 1
of âprintfâ makes pointer from integer without a cast",
because the syntax of printf is not right.
And it would have been printf("%d",i--);
Then correct answer is 531.
This is the correct answer rest all are wrong.[:)]
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / vishnu
ur printf syntax is wrong so..u'll will get syntax error
Is This Answer Correct ? | 3 Yes | 1 No |
syntax error.... in prinf...but it should be corrected then
the result will be
5
3
1
Note ...
in first run I=5; printf(i--) print I which is 5 and store 4
in i.
in second run i-- means 4-1=3 then printf(i--) print 3 and
store 2 in i.
in third run... i-- measn 2-1=1 then printf(i--) print 1 and
store 0 in i.
then decreament statement i-- store 1=-1 and when compare
-1>=0 become false and goto next statement after that loop.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / binz
Answer is
5
3
1
But you should change your printf statement to printf("%d",
i--);
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / mahender
printf prints value by using format spicefiers
bt in this printf(i--);
means
error
Is This Answer Correct ? | 1 Yes | 0 No |
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.
what is the program to display your name in any color?
why 'c' is called middle level language.
When is a “switch” statement preferable over an “if” statement?
write a C and C++ programme to implement the A,bubble sort B,quick sort C,insertion sort D,sequential search E,binary search
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.
How do you determine a file’s attributes?
advantages of pointers?
What is unsigned int in c?
#include<stdio.h> int main() { int i=0,j=1,k=2,m,n=0; m=i++&&j++&&k++||n++; printf("%d,%d,%d,%d,%d",i,j,k,m,n); }
12 Answers Capital IQ, Sasken,
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include<stdio.h>...