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

Join 107,669 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,040 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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 - 09:29 PM
Post #1


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 8


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 - 09:33 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,840



Thanked 27 times

Dream Kudos: 2325

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 - 10:36 PM
Post #3


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 8


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 - 02:05 AM
Post #4


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,300



Thanked 44 times

Dream Kudos: 1450

Expert In: C, C++

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 - 02:20 AM
Post #5


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,840



Thanked 27 times

Dream Kudos: 2325

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 - 05:49 AM
Post #6


D.I.C Addict

Group Icon
Joined: 17 Oct, 2007
Posts: 501



Thanked 2 times

Dream Kudos: 775
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: 8/29/08 11:02PM

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