Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,494 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,062 people online right now. Registration is fast and FREE... Join Now!




find maximum ,please

 
Reply to this topicStart new topic

find maximum ,please, find maximum prgram C

kornni
post 1 Jul, 2008 - 08:29 PM
Post #1


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 9


My Contributions


I want program that user enter number such as 100 then program random 100 number and find maximum


thank you
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 1 Jul, 2008 - 08:33 PM
Post #2


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,329



Thanked 57 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


Would you like fries with that? This isn't McDonald's of Coding lol...

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is online!Profile CardPM

Go to the top of the page

kornni
post 1 Jul, 2008 - 09:36 PM
Post #3


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 9


My Contributions


QUOTE(no2pencil @ 1 Jul, 2008 - 09:33 PM) *

Would you like fries with that? This isn't McDonald's of Coding lol...

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.




why program not enter 1000000

CODE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main(int argc, char *argv[])
{
  
  int i,MAX;
  scanf("%d",&MAX);
  int number[MAX];
   /* initialize random seed: */
  srand ( time(NULL) );
  
  
  
  for (i = 0;i<MAX;i++){
      number[i]=rand();  
  }
  printf("\n\n");
  int count,min,j,k;
  for(count=0;count<MAX-1;count++)
  {
       min = count;
       for(j=count+1;j<MAX;j++){
           if(number[min]>number[j])
               min = j;
       }
       if(min!=count)
       {
           k = number[count];
           number[count]=number[min];
           number[min]=k;
       }
  }
  for(i=0;i<MAX;i++){
      printf("%d\n",number[i]);
  }
  system("PAUSE");    
  return 0;
}






User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 2 Jul, 2008 - 01:05 AM
Post #4


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,433



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


There is a maximum that int can store...

If you want to use larger numbers, try google for some LargeInteger libraries or something. smile.gif
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 2 Jul, 2008 - 01:20 AM
Post #5


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,329



Thanked 57 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(gabehabe @ 2 Jul, 2008 - 05:05 AM) *

There is a maximum that int can store...

The introduction to data types includes their limits, & is always the 1st thing in any C/C++ book I've read.
User is online!Profile CardPM

Go to the top of the page

captainhampton
post 2 Jul, 2008 - 04:49 AM
Post #6


Jawsome++;

Group Icon
Joined: 17 Oct, 2007
Posts: 518



Thanked 2 times

Dream Kudos: 825
My Contributions


Try a different data type if int is too small for your particular experimentation. A "double" type should help out just fine, or if it must be ints try unsigned int
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 04:49PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month