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 ?    20 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

Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion.

2 Answers   Drona Solutions, Infosys, Vodafone, Webyog,


please tell me the logic for this C program : INPUT (string):ABCD OUTPUT :BCDA CDAB DABC

2 Answers   Mphasis,


Are enumerations really portable?

0 Answers  


When can a far pointer be used?

0 Answers  


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

0 Answers  






value = 0xabcd; for (loop = 1; (value >> 1) & 1 | loop & 1; loop++) { foo(); if (loop & 1) value >>= 1; } how many times is foo() executed?

6 Answers   Google,


What are the Advantages of using macro

0 Answers  


By using C language input a date into it and if it is right?

0 Answers   Aricent,


What are the header files used in c language?

0 Answers  


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

0 Answers  


What does the c in ctime mean?

0 Answers  


What is the scope of static variables?

1 Answers  


Categories