Solved

maximum value in array

Posted on 2006-11-09
2
250 Views
Last Modified: 2010-04-15


I have a code that can return me the maximum value in a giving array (like below ). how can I change it to return me the maximum value for each row.
for example, I wan to the code return me like

the maximum value in row 1 is: 4
the maximum value in row 2 is: 8
the maximum value in row 3 is: 4


#include <stdio.h>
#include <stdlib.h>
#include <float.h>
                                 
int t [3][3]={  {3,3,4},
                {8,2,1},
                {3,3,4}
              };                    
                   

main (){
   
   int i,j, max;
   max=t[0][0];
   
   for (i=0; i<3 ; i++){
      for (j=0; j<3; j++){
        if (t[i][j]>max)
          max=t[i][j];
      }
   }

printf("max vaule is : %d\n",max );
system("pause");
return 0;

}
0
Comment
Question by:rmtogether
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 17907651
Almost there, that should be

main (){
   
   int i,j, max;
   
   for (i=0; i<3 ; i++){
      max = 0;
      for (j=0; j<3; j++){
        if (t[i][j]>max) {
          max=t[i][j];
        }
      }
      printf("max vaule is : %d\n",max );
   }

system("pause");
return 0;

}
0
 

Author Comment

by:rmtogether
ID: 17907775
thanks your are so fast....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now