473,385 Members | 1,673 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,385 software developers and data experts.

printing matrix values

i am having a matrix in the form
12345
678910
1112131415
1617181920
2122232425

what i have tried

void printIt()
{
for (row=0; row<MAXR; row++) {
for (col=0; col<MAXC; col++) {
if (matrix[row][col])

}


still
the output must be in upper half and lower half as

1
67
111213
16171819
2122232425

and also
2345
8910
1415
20
Oct 16 '07 #1
6 3500
Meetee
931 Expert Mod 512MB
i am having a matrix in the form
12345
678910
1112131415
1617181920
2122232425

the output must be in upper half and lower half as

1
67
111213
16171819
2122232425

and also
2345
8910
1415
20
Hi,

Welcome to TSDN. Please read posting guidelines-homework and assignment .

Please paste your code what you have done so far. We can only help you if you have tried something and if you have specific problem.

Regards
Oct 16 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
if (matrix[row][col])
etc...
Same problem as yout other thread. The if statement is not complete.
Expand|Select|Wrap|Line Numbers
  1. if (matrix[row][col])
  2.  
will always be true when matrix[row][col] is not zero.
Oct 16 '07 #3
Same problem as yout other thread. The if statement is not complete.
Expand|Select|Wrap|Line Numbers
  1. if (matrix[row][col])
  2.  
will always be true when matrix[row][col] is not zero.
i tried n but confused
could u help in this
Oct 16 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
12345
678910
1112131415
1617181920
2122232425
OK. If this is your matrix, then how have you declared it??

Array elements must all be the same. The one above looks fishy. The rows are different lengths.
Oct 16 '07 #5
OK. If this is your matrix, then how have you declared it??

Array elements must all be the same. The one above looks fishy. The rows are different lengths.
the array elements are from 1 to 25 and row and col has 5 x 5 .
thatis

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

the output must be displaying the upper half and lower half

1
6 7
11 12 13
16 17 18 19
21 22 23 24 25

and the upper half as

2 3 4 5
8 9 10
14 15
20
Oct 16 '07 #6
RRick
463 Expert 256MB
The if condition is not based on the value stored in the matrix, but based the values of the row and column indices themselves.

To print the lower half of the matrix, the row indice must greater than or equal to the column indice.

To print the upper half, you do the opposite. The column indice is greater than or equal to the row indice.

Once you're inside the if condition, just print out the value.
Oct 16 '07 #7

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

Similar topics

1
by: David Rubin | last post by:
This is totally lame...How do I use iomanip's to get the equivalent of printf("%#.8x", 0xabcd); which should yield 0x0000abcd I tried
3
by: hazz | last post by:
The datareader below contains two rows of two columns but in the for loop, the values for only the first row are getting printed twice. How do I get to the values of the second row? Thanks. -hazz...
1
by: David | last post by:
Hi, I have a problem with returning a value from an external function..... My asp page is basically a list taken from a database. A date record is written from the DB, then all the...
17
by: Matt | last post by:
Hello. I've got a very strange problem. Basically I have a programme where I wish to view all the strings in the argv array so I can see what arguments are being passed to the programme. ...
2
by: widevision7 | last post by:
I am creating a web site where I want to have the same menu on each page. I created a "menu file", and put the html print statements in the file. The menu file contains html code: <table>...
6
by: backups2007 | last post by:
I have an array of values that come from a database. I used a FOR loop to retrieve each of the values and pass it on to text fields. But the instead of displaying the whole word, only the first...
3
by: okcomputer24 | last post by:
I am wanting to print a matrix grid which is derived from a list of lists. The grid should look as follows: Col 0 Col 1 Col 2 Row 0 1 2 3 Row 1 4 ...
2
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query. What we want to do is to print the values on the page in a table that correspond the to selection from the combo...
0
by: brixton | last post by:
Hello, I've got the following code that creates a texture from a .RAW file: GLuint MyGLCanvas::LoadTextureRAW( const char * filename, int wrap ) { GLuint texture; int width, height; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.