Solved

maximum value in array

Posted on 2006-11-09
2
264 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

624 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