Google Answers Logo
View Question
 
Q: C++ programming ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: C++ programming
Category: Computers
Asked by: gevancio-ga
List Price: $10.00
Posted: 30 May 2004 19:03 PDT
Expires: 29 Jun 2004 19:03 PDT
Question ID: 354074
Write a program that allows you to enter 10 item stock numbers, prices
and quantities in stock into three parallel arrays. Display all the
data in report form, that is, aligned correctly in columns. In C++
Answer  
Subject: Re: C++ programming
Answered By: tox-ga on 30 May 2004 22:48 PDT
Rated:5 out of 5 stars
 
Hi gevancio-ga,

Here is the program you requested:

#include <iostream>
using namespace std;

int main()
{
    int a[10], b[10], c[10];

    for (int i=0; i<10; i++) {
       cout << "Enter stock number for item " << i+1 << ": ";
       cin >> a[i];
       cout << "Enter price for item  " << i+1 << ": ";
       cin >> b[i];
       cout << "Enter quantity for item " << i+1 << ": ";
       cin >> c[i];
    }
    
    cout << "   Stock Number          Price       Quantity" << endl;

    for (int j=0; j<10; j++) {
       cout.width(15);
       cout << a[j];
       cout.width(15);
       cout << b[j];
       cout.width(15);
       cout << c[j] << endl;
    }


    return 0;
}


If you would like an explanation of how it works or would like me to
help you change anything to better suit your needs, please feel free
to ask.

Best regards,
tox-ga

Request for Answer Clarification by gevancio-ga on 31 May 2004 12:34 PDT
I have 2 errors when I try to run it. Unresolved external symbols ????

Clarification of Answer by tox-ga on 10 Jun 2004 03:30 PDT
Thank you for the kind rating.

Tox-ga
gevancio-ga rated this answer:5 out of 5 stars
It worked great once I entered it in Win 32 console application. Sorry
about the request for clarification. Thanks, Gary

Comments  
Subject: Re: C++ programming
From: darrenw-ga on 31 May 2004 17:51 PDT
 
Use better variable names than a,b,c,j,i. Shocking!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy