Question

Write a program and flowchart. The program should store the ages of six of your friends...

Write a program and flowchart. The program should store the ages of six of your friends in an array. Store each of the six ages using the assignment operator. Print the ages on-screen using a "for" loop.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of the code:

Sample Output:

Code to copy:

//Include required header file.

#include <iostream>

//Use the standard naming convention.

using namespace std;

//Start the main() method.

int main()

{

//Create an integer array of size 6.

int ages[6];

int i;

//Initialize each element of the array using assignment

//operator.

ages[0] = 21;

ages[1] = 22;

ages[2] = 23;

ages[3] = 24;

ages[4] = 25;

ages[5] = 26;

//Display the ages of 6 friends.

cout << "Age of all 6 friends:" << endl;

//Traverse the array of size 6 using a for loop.

for(i = 0; i < 6; i++)

{

    //Display age of each friend.

    cout << "Friend " << (i + 1) << " age: " << ages[i];

    cout << endl;

}

}

Sample Flow chart:

Add a comment
Know the answer?
Add Answer to:
Write a program and flowchart. The program should store the ages of six of your friends...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT