i=20,k=0;
for(j=1;j<i;j=1+4*(i/j))
{
k+=j<10?4:3;
}

printf("%d", k);

Answers were Sorted based on User's Feedback



i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / guest

k=4

Is This Answer Correct ?    21 Yes 3 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / valli

k=4

Is This Answer Correct ?    9 Yes 4 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / vishal bhardwaj

ans is : 4

Is This Answer Correct ?    2 Yes 0 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / abi

all the above answers are wrong!
just think the below logic...

in for loop j=1+4*20 so j=81

81<10 is false...so 3 is assigned
k+=3 ie k=k+3
k=0+3
k=3


so answer is 3

Is This Answer Correct ?    15 Yes 15 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / arun

4

Is This Answer Correct ?    2 Yes 3 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / guest

compilation error i is not declared as int

Is This Answer Correct ?    5 Yes 7 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / vignesh1988i

k=4;;;;;

Is This Answer Correct ?    1 Yes 6 No

i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k); ..

Answer / suchita

k=5 bcoz the statement k+=j<10?4:3;
here k+ increaments the value then assign to the k

Is This Answer Correct ?    1 Yes 11 No

Post New Answer

More C Interview Questions

how to implement stack operation using singly linked list

2 Answers  


which of the function operator cannot be over loaded a) <= b)?: c)== d)*

10 Answers   Cisco, CTS, Google, HCL, HP,


Why is it that not all header files are declared in every C program?

0 Answers  


what will be the output of this program? #include<stdio.h> #define cube(x) x*x*x void main() { int i,j=5; i=cube(j+3); printf("i=%d",i); }

6 Answers   IBM,


What is the best style for code layout in c?

0 Answers  






What tq means in chat?

0 Answers  


1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop

2 Answers  


we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?

2 Answers  


What does p mean in physics?

0 Answers  


#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x=%d",sqr(x+1)); } What is the value of x?

16 Answers   Accel Frontline, Opera, Oracle,


Is c dynamically typed?

0 Answers  


How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


Categories