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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   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
what is the output of the following program?
main()
{
 int c[]={2,8,3,4,4,6,7,5};
 int j,*p=c,*q=c;
 for(j=0;j<5;j++)
  {
   printf("%d",*c);
   ++q;
  }
 for(j=0;j<5;j++)
  {
   printf("%d",*p);
   ++p;
  } 
}
 Question Submitted By :: Vikram
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
Answer
# 1
2222228344
 
Is This Answer Correct ?    5 Yes 0 No
Praveen
 
  Re: what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
Answer
# 2
2222228344...

the above code can  be remodified as :
printf("%d",*q); in first printf statement to get the same
output for both printf statements



thank u
 
Is This Answer Correct ?    1 Yes 0 No
Vignesh1988i
 
 
 
  Re: what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
Answer
# 3
output is 2222228344


in loop 1

as we know that array variable contain the base address of 
the array 

*c means we are trying to print the value of contained in 
the base address which is not changed in the loop

note we can't change the base address of the array that is 
we can't do 'c++'

as in loop for 5 times contain of the base address will be 
printed as 
       22222



in loop 2

in assigned base address of the array to pointer p

here we are printing the contain of address stored in p and 
increment the value of p ( that is pointing to the next 
element of the array )

so we will get output for 2nd loop is 

       28344


overall answer is 

2222228344

 if any wroung in my aswer plz info me at

molugu.ashwin@gamil.com
 
Is This Answer Correct ?    1 Yes 0 No
Ashwin Kumar
 
  Re: what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
Answer
# 4
2222228344 will be the answer. I think everybody answered 
before me is correct.
 
Is This Answer Correct ?    0 Yes 0 No
Abhradeep Chatterjee
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); } what is the output? Ramco4
can we write a program in c for printf and scanf without using header file stdio.h  1
what is the output of the following program and explain the answer #include<stdio.h> exp() { main(5) } main(int a) { printf("%d",a); return; } Satyam3
What is encapsulation?  1
write a program in c language for the multiplication of two matrices using pointers? Ignou5
what does " calloc" do? Cadence6
what is a far pointer TCS9
what is the difference between structural,object based,object orientd programming languages? PanTerra1
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks Excel4
write a programme that inputs a number by user and gives its multiplication table.  2
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?  6
difference between semaphores and mutex?  1
To find whether a number is even or odd without using any conditional operator?? IBM4
how to exchnage bits in a byte b7<-->b0 b6<-->b1 b5<-->b2 b4<-->b3 please mail me the code if any one know to rajeshmb4u@gmail.com Honeywell3
class foo { public: static int func(const char*& p) const; }; This is illegal, why? Google6
#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf("hello \n"); return 0; } int fun() { printf("hi"); } answer is hello.how??wat is tat while(i) mean? Intel4
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } CitiGroup17
How to reverse a string using a recursive function, without swapping or using an extra memory? Motorola18
pick out the odd one out of the following a.malloc() b.calloc() c.free() d.realloc() TCS1
what is the differnce between AF_INET and PF_INET? Wipro2
 
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