473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

output 2d array help

hey dear i need help in printing 2d array i can take input from user but cannot out put it please help

#include<iostream>

using namespace std;


int main()
{int i,j,john[2][3]={{1,2,3},{5,6,7}};

for(i=1;i<=2;i++){
for(j=1;j<=3;j++){
cout<<"input value of "<<i<<" and "<<j<<endl;
cin>>john[i][j];

}

system("pause");
return 0;
}
Nov 24 '11 #1
2 1761
whodgson
542 512MB
Use the two loops again to cout<<john[i][j];
also i`m rather surprised that the declaration under main() compiles.
Nov 24 '11 #2
weaknessforcats
9,208 Expert Mod 8TB
Your loops need to start with 0 rather than 1. They need to stop < the array dimension. Remember, a [2] array has elements 0 and 1.
Nov 24 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: William Ashworth | last post by:
I have this glossary that was setup and I want to modify a bit. Here's how... ############################## printf($getWordArray); echo "</b></dt><dd>"; printf($getWordArray); echo...
5
by: ali | last post by:
Hi, I'm trying to understand the reason for different output on the following codes Code1: #include <iostream.h> int main()
7
by: justin_davies_2002 | last post by:
i need to read a text file into a character array, so i used an example fom taken from a cplusplus.com tutorial " Input/ output with files" (seebelow). The Problem i get is, it only makes a buffer...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
0
by: trinix | last post by:
Hello, I'm trying to create this program that uses arrays. The way I want to use these arrays is something that is not covered in the book I have. This is what the excersize is. A person...
3
by: sathyashrayan | last post by:
I have got a book called "Practical C Programming", ISBN:1-56592-306-5 Publisher: O'Reilly.In that book I am doing some programming exercises. Below is a one which I have got stuck. Exercise...
5
by: Stephen3776 | last post by:
I am doing an inventory control progam and trying to output a multiple array, I am getting an illegal conversion error java.lang.double !d. Can somebody tell me what I am doing wrong or if there is...
1
by: comedydave | last post by:
Hi guys, I'm new to ASP and need some array help. I need to have a shopping cart. When you visit the site it creates a session and an array. When you click add to basket it adds the item ID to...
3
by: powerej | last post by:
im having trouble printing an array with duplicate characters, i can enter and print with single characters but when i try and enter and print duplicate ones it puts blanks in my output for a sorted...
4
by: ryokubaka | last post by:
I have a function that will read a file of numbers and place them into an array. I need to create a new function that will, given that stored array, output the array to a new file. This is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.