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 / lp

Declare a integer array size at runtime:
1.declare an interget pointer. - int *ptr
2.Get the size of array from user - int n
3.using malloc() ,allocate that many number of location to
the pointer. - ptr = malloc(n*sizeof(int));
4.Make use of the dynamically allocated array. - ptr[]

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

5065


What are the types of pointers?

1119


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2545


What is call by value in c?

1008


Write a code on reverse string and its complexity.

1040


Can we use any name in place of argv and argc as command line arguments?

1077


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

2134


what is uses of .net

1742


If null and 0 are equivalent as null pointer constants, which should I use?

1225


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

2164


write a program to rearrange the array such way that all even elements should come first and next come odd

2282


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

1126


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

2081


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

1925


Explain continue keyword in c

1022