what is the purpose of the code, and is there any problem
with it.

unsigned int v[10];
unsigned int i = 0;
while (i < 10)
v[i] = i++;

Answers were Sorted based on User's Feedback



what is the purpose of the code, and is there any problem with it. unsigned int v[10]; unsign..

Answer / goutham

trying to fill the array v[i] with post increment of i,
there is no problem;
output is
v[0]=0;
v[1]=1
v[2]=2
v[3]=3
v[4]=4
v[5]=5
v[6]=6
v[7]=7
v[8]=8
v[9]=9

Is This Answer Correct ?    7 Yes 2 No

what is the purpose of the code, and is there any problem with it. unsigned int v[10]; unsign..

Answer / arka bandyopadhyay

Basically it's a tricky question and the values of v[i] cannot be predicted as there is "i++" which means 'use than change'
that is error associated with the program so using ++i will give us the correct result.

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Interview Questions

What are the Advantages of using macro

0 Answers  


What are void pointers in c?

0 Answers  


Explain what standard functions are available to manipulate strings?

0 Answers  


input any 4 digit number and find the difference of all the digits?

3 Answers   Google,


What is the difference between ++a and a++?

0 Answers  






what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7

4 Answers   TCS,


void main() { int a=1; while(a++<=1) while(a++<=2); }

4 Answers   HCL,


Give the output for the following program. #define STYLE1 char main() { typedef char STYLE2; STYLE1 x; STYLE2 y; clrscr(); x=255; y=255; printf("%d %d\n",x,y); }

2 Answers   ADITI,


swap two integer variables without using a third temporary variable?

6 Answers   Persistent,


What is wrong in this statement? scanf(“%d”,whatnumber);

0 Answers  


which operator is known as dummy operator in c?

2 Answers   Wipro,


please give me some tips for the selection in TCS.

3 Answers   TCS,


Categories