Plz Help!!!!!!!!

Pages: 123
closed account (3qX21hU5)
Since you did most of the work changing stuff I will top it off.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;

void DataIn(string Names[],long Academic[10],int A,float Grade[10],int G);  // Changed
void DataOut(string Names[],long Academic[10],int A,float Grade[10],int G); // Changed

main()
{
	string Names[10];       // Changed to a string array
	long Academic[10];
	float Grade[10];
	DataIn(Names,Academic,10,Grade,10);
	DataOut(Names,Academic,10,Grade,10);

	cin.ignore(100, '\n');
	cin.get();

}

void DataIn(string Names[],long Academic[10],int A,float Grade[10],int G)   // Changed
{

	cout<<"Enter students names: \n";
	for(int row=0;row<10;row++)
	{
		cin>>Names[row];    // Changed so we store each name in the array of strings
	}

	cout<<"Enter the Academic Numbers: \n";
	for(int i=0;i<10;i++)
	{
		cin>>Academic[i];
		cin.ignore();
	}

	cout<<"Enter thier Grades: \n";
	for(int k=0;k<10;k++)
	{
		cin>>Grade[k];
		cin.ignore();
	}

}

void DataOut(string Names[],long Academic[10],int A,float Grade[10],int G)  // CHnaged
{
        cout << left;
        cout <<"\n"<<setw(10) << "Serial" << setw(25) << "Name" << setw(15) << "Academic No." << setw(10)
             << "Grade" << endl << endl;
	for(int i=0;i<10;i++)
	{
		cout << setw(10) << (i + 1) << setw(25) << Names[i] << setw(15) << Academic[i] << setw(10) << Grade[i] << endl;
	}

}
LOL :). ok thanks
now about my other question i want when for example when i enter the 2nd name i leave it blank for example the printed table will be like this

Serial         Names                     Academic No         Grade
1	  Mohammed Khalid	                 1                      10
2	  			                         			
3	  Mohammed Khalid	                 3                      30
4	  Mohammed Khalid	                 4                      50					
5         Mohammed Khalid                        5                       60
6	  						
7	  Mohammed Khalid	                 7                      70
8	  			
9	  Mohammed Khalid	                 9                      90
10	  Mohammed Khalid               	10                     100
Last edited on
hey guys!!!!!!!!
Do you mean that when Names[i] is an empty string, then not printing the three values? You can ask from string how long it is.


Btw, parameters A and G of the DataOut(). Think about their purpose.
ok .
now i have a major prblem when i enter a name like (Mohammed Khalid)
the compiler take Mohammed as a name and Khalid as a name ..... why
i have solved the problem using this
getline(cin,Names); \\the null doesn't take affect with the string anyway right!!!
than u all 4 helping me :)));
Last edited on
closed account (3qX21hU5)
You need to use getline (cin, Names [row]) instead of cin. If you don't cin only reads up to the first whitespace.

Topic archived. No new replies allowed.
Pages: 123