main()

{

int x=5;

for(;x!=0;x--) {

printf("x=%d\n", x--);

}

}

a. 5, 4, 3, 2,1

b. 4, 3, 2, 1, 0

c. 5, 3, 1

d. none of the above

Answers were Sorted based on User's Feedback



main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } ..

Answer / guest

d) Infinite loop as x is decremented twice, it never be 0

and loop is going on & on

Is This Answer Correct ?    13 Yes 0 No

main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } ..

Answer / ajit

first error in 4 step as syntax error
this is so that for(x!=0;x--) answer is d becoze here
not defined x=?

Is This Answer Correct ?    0 Yes 10 No

Post New Answer

More C Code Interview Questions

Write a C program to add two numbers before the main function is called.

11 Answers   Infotech, TC,


Implement a t9 mobile dictionary. (Give code with explanation )

1 Answers   Amazon, Peak6, Yahoo,


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

6 Answers   Fusion Systems GmbH,


const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above

1 Answers   emc2, HCL,






#include<conio.h> main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }

1 Answers  


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,


find simple interest & compund interest

2 Answers  


main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16

4 Answers   HCL,


Program to Delete an element from a doubly linked list.

4 Answers   College School Exams Tests, Infosys,


pls anyone can help me to write a code to print the values in words for any value.Example:1034 to print as "one thousand and thirty four only"

2 Answers  


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


Categories