ALLInterview.com :: Home Page Forum9.Com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories >> Software >> Programming-Languages >> C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
Question
main()
{
  int i = 1;
  int num[] = {1,2,3,4};
  num[i] = i++;
  printf("%d", num[i]);
}

what will be the output?
}
 Question Submitted By :: Sid08
I also faced this Question!!     Rank Answer Posted By  
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 1
complier error
 
Is This Answer Correct ?    1 Yes 1 No
Gowtham
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 2
num[i]=i+1
  num[1]=1+1=2, but num[1] is 1.so there is a error...
 
Is This Answer Correct ?    0 Yes 1 No
Sathya
 
 
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 3
expression likes
num[i]=i++;
are always compiler dependent.
it is a bad programing to use such expression.
 
Is This Answer Correct ?    0 Yes 1 No
Vijay
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 4
3 is correct answer
 
Is This Answer Correct ?    1 Yes 0 No
Raj
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 5
num[i] is num[1] and its reassigned as i++ that is 1 thus it
will print 1.
but im not at all sure about this..
 
Is This Answer Correct ?    0 Yes 1 No
Mortal
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 6
It will print answer 1 because in case of++ atfairt assing
and then increment..
 
Is This Answer Correct ?    0 Yes 0 No
Aniruddha
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 7
4 is output
 
Is This Answer Correct ?    0 Yes 0 No
Lukz
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 8
The output is 3
 
Is This Answer Correct ?    1 Yes 0 No
Vyasaraj.s
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 9
out put  is 3  and  it  is correct
 
Is This Answer Correct ?    1 Yes 0 No
Lucky
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 10
3 is the answer bcoz
i=1
num[i]=i++;
num[1]=2;
here i=2
printf("%d", num[2]);

here 3 is there at position 2 .
so answer is 3
 
Is This Answer Correct ?    0 Yes 0 No
Pragathi
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 11
it will lead to Undefined behaviour, both answers 3 aand 4 
are correct.
 
Is This Answer Correct ?    0 Yes 0 No
Abdur Rab
 
 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
define function Assurgent4
What is alloca() and why is its use discouraged?  1
How would you find a cycle in a linked list?  2
what is meant by c  3
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola2
How do we swap or interchange any 2 numbers without using Temporary variable...Anybody can pls answer it.. Thanks in Advance US-Technology5
Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.  1
what is the difference between declaration ,defenetion and initialization of a variable? LG-Soft4
2)#include<iostream.h> main() { printf("Hello World"); } the program prints Hello World without changing main() the o/p should be intialisation Hello World Desruct the changes should be a)iostream operator<<(iostream os, char*s) os<<'intialisation'<<(Hello World)<<Destruct b) c) d)none of the above Siemens4
to find the program of matrix multiplication using arrays  1
what will be the output: main(){char ch;int a=10;printf("%d",ch);} Wipro24
f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c? Geometric-Software4
What is difference between the following 2 lines…. int temp = (int)(0x00); int temp = (0x00int); Bosch3
Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++; ITCO3
Why does not use getgh(); and <conio.h> in c language. Elofic1
Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error IBM3
what is the difference b/w compiler and debugger?  1
There are 3 baskets of fruits with worng lables,one basket has apple,another basket has orange,another has combination of apple and orange,what is the least way of interchange the lables. Google8
palindrome for strings and numbers----Can anybody do the prog? TCS4
What is external and internal variables What is dynamic memory allocation what is storage classes in C  2
 
For more C Interview Questions Click Here 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com