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
What is the most efficient way to store flag values?
Explain the meaning of keyword 'extern' in a function declaration.
Does c have enums?
what is reason of your company position's in india no. 1.
What is the difference between text and binary i/o?
Can we declare variable anywhere in c?
Here is a good puzzle: how do you write a program which produces its own source code as output?
What is #include conio h?
What is int main () in c?
Can a function argument have default value?
How can you increase the size of a dynamically allocated array?
I need previous papers of CSC.......plz help out by posting them.......
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
Write a program to show the change in position of a cursor using c
Why can arithmetic operations not be performed on void pointers?