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 2n 4c mean?

1196


When was c language developed?

1145


Define and explain about ! Operator?

966


Explain what is the best way to comment out a section of code that contains comments?

1102


What is nested structure?

1007


Explain b+ tree?

1018


what do u mean by Direct access files? then can u explain about Direct Access Files?

2047


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)

2071


Tell me with an example the self-referential structure?

958


What does typedef struct mean?

1055


Write a program to reverse a given number in c?

993


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1035


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1240


What does static variable mean in c?

1068


Explain why can’t constant values be used to define an array’s initial size?

1319