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 the error 'Null Pointer Assignment' mean and what causes this error?
Is register a keyword in c?
What happens if header file is included twice?
What do you mean by dynamic memory allocation in c?
What is the code for 3 questions and answer check in VisualBasic.Net?
What is string concatenation in c?
Write a c program to demonstrate character and string constants?
What are the key features in c programming language?
How do I get a null pointer in my programs?
What is d'n in c?
How many parameters should a function have?
please give me some tips for the placement in the TCS.
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
Tell me the use of bit field in c language?
Explain what are its uses in c programming?