Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What does the error 'Null Pointer Assignment' mean and what causes this error?

1224


Is register a keyword in c?

1047


What happens if header file is included twice?

1152


What do you mean by dynamic memory allocation in c?

1105


What is the code for 3 questions and answer check in VisualBasic.Net?

2163


What is string concatenation in c?

1094


Write a c program to demonstrate character and string constants?

2192


What are the key features in c programming language?

1076


How do I get a null pointer in my programs?

1115


What is d'n in c?

1124


How many parameters should a function have?

1196


please give me some tips for the placement in the TCS.

2115


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3095


Tell me the use of bit field in c language?

1071


Explain what are its uses in c programming?

1064