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 is a file descriptor in c?

0 Answers  


consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0;} if n=2, what is the value of sum a.0 b.6 c.3 d.none

7 Answers   TCS,


Is a pointer a kind of array?

0 Answers  


What are the different types of pointers?

4 Answers   HCL, TCS,


Is array name a pointer?

0 Answers  






How can I check whether a file exists? I want to warn the user if a requested input file is missing.

0 Answers  


Is it possible to create recycle bin in mobiles?

2 Answers  


What is the difference between static and global variables?

1 Answers  


A array contains dissimilar element how can we count, and A array contains dissimilar element how can we store in another array with out repetition.

4 Answers  


What is the heap in c?

0 Answers  


I want tcs placement papers of 2004-2009 , its urgent

6 Answers   TCS, Wipro,


What is the purpose of macro in C language?

0 Answers   Fidelity,


Categories