Subj : Re: Random Integer Solutions...Help Please... To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Sun Jun 27 2004 01:43 pm There are a couple if items that you should know about. If you end a string and nothing comes between it and the quote beginning the next string, the compiler will combine them. This is part of how the language standard says C and C++ will work. When scanf reads a number it reads up through the last character of the number so the Enter key (the '\n') is left in the input buffer. The next time you call scanf it will end without finding a number because what it saw in the input was the enter key. The easiest solution is to read in a string and use sscanf to get the number from it. int smallest a; char buffer[133]; printf("Input how many integers you will give\n" "and I will tell you the smallest of the group: "); fgets(buffer, sizeof(buffer), stdin); sscanf(%d", &a); An algorithm for doing what you want is to create a variable to hold the smallest number. For each number that comes in you compare to the value of that variable. If this new number is smaller then you assign the value of this new number to the smallest number variable. > for (total = 0; counter <= a; counter++); You don't need either of 'counter' or 'total' because you already have 'a' as the number of items (not a good choice of variable names - the name 'a' does not imply what the variable is used for). You also increment counter after using it but have no use for it. ++counter would be better. This might work better: for ( ; a > 0; --a) .. Ed > Jeremy Pham wrote in message > news:40dedb5a$1@newsgroups.borland.com... > > #include > > main() > { > int smallest, a; > > int counter = 1, total; > > printf("Input the number of integers you will input,\nand I will tell you the smallest of the group: "); > scanf("%d", &a); > > printf("Input a value: "); > scanf("%d", &num); > > for (total = 0; counter <= a; counter++); > > This is the program I made so far. I have to make a program that determines the smallest number of a group of numbers, with the first number entered being the number of numbers we will use. The numbers are all integers. I'm very confused with the mathematical concept to simplify the process in making this type of program. Could someone please tell me the programming functions, or at least the mathematical solution? > > Thanks for all your help guys, > Jeremy Pham .