void main()
{
int a[]={1,2,3,4,5},i;
for(i=0;i<5;i++)
printf("%d",a++);
getch();
}
Answer Posted / vikas thakur
The answer is error.
The reason is that we can't increment a constant(the
variable int a[] ). The expression int a[] is the address
where the system had placed your array and it will remain
to stay at that address until the program terminates. you
can't increment an address but you can increment a pointer.
.....the correct program would be....
void main()(
int a[]={1,2,3,4,5},i;
for(i=0;i<5;i++)
printf("%d",a[i]);
getch();
}
....in another way.....
void main()(
int a[]={1,2,3,4,5},i;
int *p;
p = a;
for(i=0;i<5;i++)
printf("%d",*(p++));
getch();
}
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Tell us the use of fflush() function in c language?
What is string length in c?
Do you know what are bitwise shift operators in c programming?
What is c variable?
What is a pointer on a pointer in c programming language?
Explain pointer. What are function pointers in C?
What are the data types present in c?
Write a program to print fibonacci series without using recursion?
What are the disadvantages of a shell structure?
Do you know pointer in c?
What is the use of parallelize in spark?
Which is better oop or procedural?
When should you use a type cast?
What language is windows 1.0 written?
What header files do I need in order to define the standard library functions I use?