Question 64
Explanation
What is the output of following C program?
# include <stdio.h>
main( )
{
int i, j, x = 0 ;
for ( i= 0; i < 5; ++i )
for ( j = 0; j < i ; ++j ){
x += (i + j - 1);
break ;
}
printf ( "%d" , x );
# include <stdio.h>
main( )
{
int i, j, x = 0 ;
for ( i= 0; i < 5; ++i )
for ( j = 0; j < i ; ++j ){
x += (i + j - 1);
break ;
}
printf ( "%d" , x );
Previous | Next |
UGC NET CS December 2019 - Question 63 | UGC NET CS December 2019 - Question 65 |
Break statement restricts inner-for-loop to execute only once for all value of i > 0
Inner for loop value j initializes to 0 every time.
So, option 1 is correct answer