Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

maximum value in array

Posted on 2006-11-09
2
Medium Priority
?
279 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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 pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

916 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