How to Input data directly into the table?

Hi There!
I am dealing with two dimensional arrays. I am trying to make a table for Number of seats won By different parties in different provinces.
But the issue is I want to input the entries in the table directly using "cin statement" but it's not happening correctly.(Since each entry appears in the next row). Please Help!
My code is follows:



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
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int m[3][4],i,j,sum,sum1,Csum,Rsum;
	
	
	cout<<"       Punjab  Sindh  KPK  Balochistan"<<endl;
	cout<<"______________________________________"<<endl;
	for(i=0;i<3;i++)
	{
		if(i==0)
		cout<<"PPP ";
		else if(i==1)
		cout<<"PTI ";
		else 
		cout<<"PMLn";
		
		for(j=0;j<4;j++)
		{
			
			cout<<setw(8);
			cin>>m[i][j];
			
		}
		cout<<endl;
		
	}
	
	
	return 0;
}
Last edited on
What makes you think it's not happening correctly?

Your cin statement at line 24 appears that it will read in 12 entries into your table.
Having you tried printing out the table after inputting it?

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Topic archived. No new replies allowed.