TCS
Company
Programming
Program
#include
int main()
{
int i,j;
for(i=0;i<5,i++)
i=j=i;
j=0;
printf("%d",j);
}
Read Solution (Total 15)
-
- There are two errors in this program
1.header file is missing (stdio.h)
2.in for loop there used in comma(,) operator it is an syntax error.
If the 2 error are corrected the output of the program is 0 - 5 years agoHelpfull: Yes(11) No(5)
- whatever j is initialised first , it initialished to zero at last So answer will be 00000
- 5 years agoHelpfull: Yes(7) No(3)
- first of all ,
according to given question ans is compiler error, error in the following
1. #include(stdio.h)----"stdio.h" is missing
5. for(i=0;i - 5 years agoHelpfull: Yes(3) No(3)
- Output of this program is 0, because j initialize in outside of loop
- 5 years agoHelpfull: Yes(2) No(0)
- ---we need to include stdio like header file in include so that output and input will work
---inside for loop (need to use ;) - 5 years agoHelpfull: Yes(0) No(2)
- output 00000
iteration 1:
i=0
i - 5 years agoHelpfull: Yes(0) No(0)
- 0 ie j was not increment
- 5 years agoHelpfull: Yes(0) No(0)
- if we ingore the syntactical errors then it get infinate loop
- 5 years agoHelpfull: Yes(0) No(1)
- compilation error
- 5 years agoHelpfull: Yes(0) No(0)
- ignoring typo errors made by questioner..if the for loop executed correctly then the result printed is..
0
0
0
0
0 - 5 years agoHelpfull: Yes(0) No(0)
- since in for loop no brackets are provided it considers only single statment
and then given j=0
so it prints j as 0 - 5 years agoHelpfull: Yes(0) No(0)
- ignoring the error output will be
0
0
0
0
0 - 4 years agoHelpfull: Yes(0) No(0)
- j is initialized out of the loop . Hence 0 .
- 4 years agoHelpfull: Yes(0) No(0)
- Compilation error
- 4 years agoHelpfull: Yes(0) No(0)
- As we know that,in 'for' there are two semicolon but there is only one that's why error
- 3 years agoHelpfull: Yes(0) No(0)
TCS Other Question