sign up I login
 advanced
refer a friend - earn nickels!!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: array size
Forum Index -> Computer Science like the article? email it to a friend.  
Author Message
maha (0)

New kid on the Block

Olaaa!! Perrrfect answer. 0  [0 rates]

maha's Avatar

total posts: 11    
offline Offline

why is the declaration    int  a[n] ; invalid where n is not a constant integer

    
deedee (1963)

Blazing goIITian

Olaaa!! Perrrfect answer. 325  [494 rates]

deedee's Avatar

total posts: 1015    
offline Offline

ya itz


n can b ne integer


like


int ar[5]


so it contains five elmnts max and min it can contain en no. bt less then 5


don't walk as if u rule d world
walk as if u dont care who rules d world

-this is knw as attitude



B who u r and say wat u feel ......
coz those who mind don't matter ........
and those who matter dont mind ......... :)


 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
shobhita (196)

Blazing goIITian

Olaaa!! Perrrfect answer. 30  [53 rates]

shobhita's Avatar

total posts: 384    
offline Offline
ya its the format n u cannot change it............u hv to give some const. value like any no.there in the bracket

trying to reach higher than the highest but with controlled ambition
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
maha (0)

New kid on the Block

Olaaa!! Perrrfect answer. 0  [0 rates]

maha's Avatar

total posts: 11    
offline Offline

but how come  dynamic arrays are allowed......help me please

 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
atul_sinha89 (46)

Hot goIITian

Olaaa!! Perrrfect answer. 6  [14 rates]

atul_sinha89's Avatar

total posts: 127    
offline Offline
first of all dynamic arrays are not allowed and

whenever we define an array its size must be constant becoz an array cannot have variable sizes .....


u can do like this..

where u include header files...


#define num 10;

this defines num = 10;


int ar[num];

this is valid or you can use any constant vaue





rate me if usefull.

. . . : : | | : : A T U L : : | | : : . . .

||~::~||THE ONLY THING YOU DON'T KNOW IS THAT WHICH YOU DON'T KNOW||~::~||
 this reply: 4 points  (with Olaaa!! Perrrfect answer.   in 2 votes )   [?]
 
You have to be logged on to rate
  
adityaraj (72)

Blazing goIITian

Olaaa!! Perrrfect answer. 10  [21 rates]

adityaraj's Avatar

total posts: 390    
offline Offline

u can keep those brackets empty.

 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
achman (58)

Hot goIITian

Olaaa!! Perrrfect answer. 10  [14 rates]

achman's Avatar

total posts: 127    
offline Offline

This is true for C++ in general.


In JAVA you can even allocate array size dynamically

 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
pratik20990 (118)

Hot goIITian

Olaaa!! Perrrfect answer. 16  [35 rates]

pratik20990's Avatar

total posts: 147    
offline Offline
atul ws right or u can do by this logically similar method-

const int n=10;
int arr[n];
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
 
Forum Index -> Computer Science
Go to:   

Top Offers for goIITians
Correspondence Courses
Brilliant Tutorials
Narayana Institute
Aakash Institute
Classroom/Crash Courses
Narayana - Kota , Delhi , Others
Brilliant Tutorials - Class , Crash
Aakash Institute - Medical , Engg
Online Test Series
Brilliant Tutorials
Narayana Institute
Aakash Institute
Mahesh Tutorials
AMITY      Sri Chaitanya