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
What does 2n 4c mean?
When was c language developed?
Define and explain about ! Operator?
Explain what is the best way to comment out a section of code that contains comments?
What is nested structure?
Explain b+ tree?
what do u mean by Direct access files? then can u explain about Direct Access Files?
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
Tell me with an example the self-referential structure?
What does typedef struct mean?
Write a program to reverse a given number in c?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What does static variable mean in c?
Explain why can’t constant values be used to define an array’s initial size?