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 Posted / ashwin kumar

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 ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is assignment operator?

626


What is the use of function overloading in C?

678


What is the use of getch ()?

636


What is difference between structure and union in c?

546


What is quick sort in c?

585






How will you divide two numbers in a MACRO?

713


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

611


Why malloc is faster than calloc?

592


What is strcpy() function?

657


What is an operator?

656


How can I call a function with an argument list built up at run time?

639


What is character set?

685


What is a macro?

657


What is the difference between call by value and call by reference in c?

619


What math functions are available for integers? For floating point?

625