[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Finding Largest

main ()
{

for ( i ...  ; {
 fscanf ( .... . .ect );
arr[i]=smth;  //smth comes from txt and must use array to reach every integer
}

printf("%d", findLarge (arr));

return 0;

}

findLarge(smth) {

what should i do ? other numbers can be sorted ?

}

and what is the function header ?
0
thefirstfbli
Asked:
thefirstfbli
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
_iskywalker_Commented:
you should format arr[i] to ints, then you can use qsort to sort them.
0
 
Razor2k5Commented:
try to use binary search and Functional Macros...

e.g.
#define max(a,b) (return a>=b?a:b)
0
 
John KawakamiCommented:
Why not just scan over the array of ints, and keep track of the largest value, then return it?

function findLarge(char **arr, int count)
{
 int i, largest=0, count;
 for(i=0;i<count;i++)
    if (arr[i] > largest)
       largest=arr[i];
 return largest;
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now