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...

How can I set an array's size at run time?

Answer Posted / nithin

int main()
{
int i, max;

// Array
int *a;

printf("Enter the size of array\n");
scanf("%d", &max);

//Run time size allocation of an array
a = (int*)malloc(max * sizeof(int));

for(i = 0; i < max;i++)
{
a[i] = i * 2;
printf("value of element %d is %d\n", i, a
[i]);
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you return multiple values from a function?

1113


Explain what is a 'locale'?

1078


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1819


What is memcpy() function?

1116


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3939


Is null always defined as 0(zero)?

1101


What is a volatile keyword in c?

1163


code for replace tabs with equivalent number of blanks

2156


What is variable declaration and definition in c?

897


What is the full form of getch?

1272


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

1150


What is meant by errors and debugging?

1100


What is the difference between declaring a variable by constant keyword and #define ing that variable?

3361


Write a program to use switch statement.

1128


How to write c functions that modify head pointer of a linked list?

983