Pa help c++ array

Status
Not open for further replies.

Elecit23

Eternal Poster
Screenshot_2022-02-23-08-55-41-44_e2d5b3f32b79de1d45acd1fad96fbb0f.webp

Pa help po kung paano mag base yung array ko sa input ng user if he/she input 1000 dapat yung array ku is 1000. Tyia
 
So ang idea jan is kunin mo ung input value dun sa "Estimated Number" and make sure that it is an integer type.

Then on declaring other variables you use that value.

Example:
C++:
int x;
cout << "Estimated Number of residents: "; // Type a number and press enter
cin >> x; // Get user input from the keyboard

Then use that variable while declaring other arrays:
C++:
string name[x], age[x];
int i;
    cout<<"Name";
    for(i=0; i<x; i++)
        cin>>name[i];
    cout<<"\n Age:";
    cin>>age[i];
    .......
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 380
    Views
  • 2
    Participants
Last reply from:
blademp119

Trending Topics

Online now

Members online
1,075
Guests online
1,215
Total visitors
2,290

Forum statistics

Threads
2,271,826
Posts
28,938,281
Members
1,237,860
Latest member
gstave_fox
Back
Top