Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2009, 04:28 AM
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Unhappy Please, answer my question.

Write a program to read a matrix of size m x n from the keyboard and display the same on the screen using functions.
 
Old May 27th, 2009, 03:36 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Obviously homework for a class.

If we do your homework for you, how will you ever learn??

If you would *TRY* to write the code, if you would mostly get it working and have some bug, *THEN* you might get help.

But nobody should do homework for you.
 
Old May 29th, 2009, 01:11 AM
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Unhappy Thank you for your suggestion.

Please correct my code.

#include <iostream>
using std::cout;
using std::cin;

int matrix(void);
int main()
{
matrix();
return 0;
}
int matrix(void)
inta[50] [40],i,j,m,n;
cout << "Enter dimention of matrix\n";
cin >> m >> n;
cout << "Enter elements of matrix\n";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin >> a[i] [j];
cout << "\nThe given matrix is: ";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cout << a[i] [j];
return o;
}
 
Old May 29th, 2009, 02:25 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Your function matrix is missing its starting { character.

You are missing a space after the keyword int.

You have a bogus { aft the next-to-last "for".

You are using return o; but you never define the variable o.

Those I see just off the top of my head. There might be other errors.

What happens if the user enters 45 as the matrix dimension?

Ever heard of COMMENTING code?
The Following User Says Thank You to Old Pedant For This Useful Post:
Mpandey (May 29th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question and Answer DTD ROCXY XML 2 November 29th, 2008 01:15 AM
Question and Answer Moduel ROCXY All Other Wrox Books 2 November 29th, 2008 01:14 AM
Book does not seem to answer my question Alfred BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 0 October 31st, 2008 11:47 AM
This has to be a simple question to answer. Bill_Thompson Beginning VB 6 1 March 7th, 2006 01:04 PM
Answer this code question jaimini VB.NET 2002/2003 Basics 3 November 27th, 2004 07:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.