I am brand new to C++. I havent done any programming whatsoever. I am taking a class in school for it and need a lot of advice/hints from you experts out there. I am not asking you to write the program for me, I am asking for your help/hints/advice in teaching me how to write it since my teacher cant. I am supposed to write an inventory program with the following info: There are two seperate columns (product name & product code) with 6 entries in each column.
Product Name Product Code
Product A 16-M978
Product B 82-C231
Product C 49-H293
Product D 35-J596
Product E 55-Y539
Product F 97-T810
Please do not laugh but this is all i have so far.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string product; //product srting
string code; //code numer string
ANY help would be much appreciated to further my learning process. THANK YOU
And just so you know:
-endl ends the line and starts on a new line.
-\t adds a tab in between Product and Product code
I'm not sure if this is what you want though.
Edit:Or as umz says, you could put products and product codes in 2 separate arrays of strings and use a for loop to print them one by one.
In which case the code would be:
Although thats not exactly what umz said :P
I think you should stick with the first way though, since you're new and probably haven't learnt loops yet.
OK i got the product string [6] and code string [6] set up like above.
now the problem i am having is getting to display whats in the two strings. how would i do that??? THANX
You use the for loop like poke386 shows. When all the data is stored in the arrays each one has a reference e.g. arr1[0] = "Product A" or whatever, you just gotta use the loop to go through the array and cout<< them all.
Use the above code from poke386 as a guideline