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;
}
}
Answers were Sorted based on User's Feedback
Answer / vignesh1988i
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 ? | 2 Yes | 0 No |
Answer / 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 |
Answer / abhradeep chatterjee
2222228344 will be the answer. I think everybody answered
before me is correct.
Is This Answer Correct ? | 1 Yes | 0 No |
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }
Is swift based on c?
what is the difference between #include<stdio.h> and #include"stdio.h" ?
What is pointer to pointer in c with example?
What is d'n in c?
HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Explain how to reverse singly link list.
Find MAXIMUM of three distinct integers using a single C statement
Explain the term printf() and scanf() used in c language?
What are the types of i/o functions?
What does extern mean in a function declaration?