Help !!

This is a discussion on Help !! within the C++ Programming forums, part of the General Programming Boards category; I dont know how to do this.. 1. Write a program that finds the smallest of several integers. Assume that ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    19

    Help !!

    I dont know how to do this..


    1. Write a program that finds the smallest of several integers. Assume that the first value read the nubmer of values remaining.

    2. Write a program that calculates and prints the product of the odd integers from 1 to 15.

    Thank-you for your help..
    Last edited by Aznmask; 11-07-2002 at 04:26 PM.

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Post some code and we'll be glad to help.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    I wish i can.. but i really fall behind the class. czu my teacher doesn't teach us. Also i have problem with my C++ program (quincy97) which not compatible with XP.. (waste me so much time there). Man C++ already so hard.. but finding a good C++ compile is HARDER THAN I EXPECT!!!

    BUt finally today i found out this forum.. i hope all your great smart ppl will help me.

  4. #4
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    First of all, a compiler...

    Bloodshed provides a package including the mingw compiler and an integrated IDE, free to download, here.

    Second, your problem...

    You are going to have to at least make an attemmpt, and post the result thereof. We have a policy here about doing homework, because it hurts everyone involved in the end. Just type out the program as best you know how and we will take a look at it for you.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Hmmm you sould distressed. I don't really like helping people who haven't got anything to build on. Here is a small sample:

    Code:
    // this is all c code
    int find_smallest(int *array, int size) {
        register int i;
        int smallest = 10;
        for(i = 0; i < size; i++)
            if(array[i] < smallest)
               smallest = array[i];
    
        return smallest;
    }
    
    int main(int argc, char **argv) {
       int array[] = { -1, 2, 3, -3, 7 };
       printf("%d", find_smallest(sizeof(array)>>2); 
    }
    I didn't make this code exactly newbie friendly, especially considering the fact that most newbie C++ programmers are affraid of C. Also I put one inhierent flaw in the program. Enjoy.

  6. #6
    alpha
    Guest
    as far as quincy97, try quincy2000 or quincy2002. i have xp also and use quincy2000 build 12, i also use dev-C++ 4.01, but i dont really like it too much. plus what is wrong with it, is it the mouse scroll, because it is supposed to work, but it doesn't.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    I using Win2K.

    I love my Computer Programming's computer czu they have Win95 installed and it work well with Quincy97. Of course it can compile, build , and tell u where the error. But Dev4 not friendly.. doesn't show u where is the mistake. I prefer QUincy97.

  8. #8
    alpha
    Guest
    I prefer quincy also. i would recommend trying quincy2000, you could use mingw and borland compilers with it. i haven't tried quincy97 though, but try quincy2000, see if you like it.

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    Why not try Quincy 2002 I have it...

    Yah you have to go to mingw.com to d/l the software and then d/l the quincy2002.exe (dont know where to d/l czu i got it from my friend) then u extract the file in the folder where your mingw installed.. then enjoy your quincy2002.

  10. #10
    alpha
    Guest
    i tried quincy2002, its okay, i prefer quincy2000 because of the availability to use borland bcc55 compiler with it, thats all...

    d/l is at www.alstevens.com/quincy.html

  11. #11
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    1 - Put the numbers into an array. The first number in the array (i.e MyArray[0]) is the number of integers in the array (or the number of valid integers to be tested).

    Remember that an array starts at zero, so a five element array goes form zero to four. In your case, MyArray[1] to MyArray[4] would contain the integers to be compared. You could probably initialize a large array to make the program more flexable.

    Use "if" and "<" (less than) in a loop and step through the array elements and find and save / display the smallest.

    2 - Make a loop that starts at one and counts by 2. (1+2=3... +2 = 5...

    Remember that C++ is not algebra. It's not an equation... So you can write x = x+2, or x= x*(x+2).

    Compilers - I use Microsoft Visual C++ (and the antique Microsoft Quick-C). I had frustration getting these set-up initially too. So don't give up! IMHO Installing and setting-up a compiler and getting "Hello World" to compile and run always seems more difficult than is should be! [U]

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21