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


Please Help Members By Posting Answers For Below Questions

Tell us the use of fflush() function in c language?

625


What is string length in c?

597


Do you know what are bitwise shift operators in c programming?

575


What is c variable?

540


What is a pointer on a pointer in c programming language?

607






Explain pointer. What are function pointers in C?

616


What are the data types present in c?

617


Write a program to print fibonacci series without using recursion?

594


What are the disadvantages of a shell structure?

682


Do you know pointer in c?

572


What is the use of parallelize in spark?

566


Which is better oop or procedural?

616


When should you use a type cast?

578


What language is windows 1.0 written?

563


What header files do I need in order to define the standard library functions I use?

526