ALLInterview.com :: Home Page KalAajKal.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  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
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
 Programming Languages AllOther interview questions  Programming Languages AllOther 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 ?    4 Yes 3 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 5 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 ?    3 Yes 2 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 ?    8 Yes 3 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 3 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 3 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 3 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 ?    7 Yes 3 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 ?    5 Yes 1 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 ?    3 Yes 1 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 2 No
Abdur Rab
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 12
output
2
 
Is This Answer Correct ?    1 Yes 2 No
Ssssssssss
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 13
the answer will be 3 b'coz whatever the "num[i] = i++;" 
this expression the output will be depend's on "i" and 
at last i will be 2 and num[2]=3 which is the answer.
 
Is This Answer Correct ?    4 Yes 0 No
Xyz
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 14
correct answer is 2 bcz once assign only that will take as 
that value
 
Is This Answer Correct ?    0 Yes 2 No
Raju
 
  Re: main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }
Answer
# 15
Idiots please don't give wrong answers. While you answer 
the questions, please check the output practically and post
 
Is This Answer Correct ?    0 Yes 0 No
Vinay
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is difference b/w extern & volatile variable?? Teleca2
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??  3
Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE; Accenture4
WHAT IS THE DIFFERANCE BITWIN GETS();AND SCANF();  2
void swap(int a,int b) { a=a+b; b=a-b; a=a-b; } in this code always gives the same result for all case TCS7
what does " calloc" do? Cadence6
wap in c to accept a number display the total count of digit  4
Suppose I want to write a function that takes a generic pointer as an argument and I want to simulate passing it by reference. Can I give the formal parameter type void **, and do something like this? void f(void **); double *dp; f((void **)&dp);  1
main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output?? Ramco13
What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?  3
what is the use of call back function in c?tell me with example  1
how to find sum of digits in C? CTS10
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 IBM4
program to find middle element of linklist? Huawei1
what are the general concepts of c and c++  1
CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION.  6
write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101) Bosch1
how can we use static and extern?and where can we use this? Excel3
palindrome for strings and numbers----Can anybody do the prog? TCS6
printf("%d",(printf("Hello")); What it returns? TCS23
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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