Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

maximum value in array

Posted on 2006-11-09
2
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

688 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