#include
static int count;
int incr( ) {return ++count;}
int main( )
{
int arr[ ]={1, 2, 3, 4};
arr[count++]=incr( );
printf("arr[count]=%d\n", arr[0]);
printf("arr[count]=%d\n", arr[1]);
printf("arr[count]=%d\n", arr[2]);
printf("arr[count]=%d\n", arr[3]);
}
Sam HobbsPosted Jun 21, 2010, 3:03 PM
What you can also do to get help here is to describe what the program does as best as you can. If you have a specific question then ask about that. Since you are a student, the best help for you is to help you learn; it does not help you if you get all the answers from others.
Amit KumarPosted Jun 21, 2010, 4:05 AM
Marimuthu ArigovindasamyPosted Jun 21, 2010, 3:42 AM
because of this ++ in arr[count++]
count = 1
count value again increasing by "return ++count"
count = 2
arr[2] means 3 (arr[0] = 1, arr[1] = 2)
Amit KumarPosted Jun 21, 2010, 3:23 AM
of this program
#include
#include
static int count;
int incr( ) {return ++count;}
int main( )
{
int arr[ ]={1, 2, 3, 4};
arr[count++]=incr( );
printf("arr[count]=%d\n", arr[count]);