Thread: programs

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    2

    Question programs

    Hey guys, I'm sorry to do this....i know ppl are not expected to do entire programs....but i really need these done asap!(before thursday!) . I'm in a bit of a tight situation....any help would be greatly appreciated. thanx

    1) Write a function that accepts the lengths of three sides of a triangle and returns whether the triangle is right-angled or not.

    2) Write a function, which given an integer Num, classifies it as ‘perfect’, ‘abundant’ or ‘deficient’. A number is perfect if the sum of its divisors (excluding the number itself) is equal to the number, e.g. 6. A number is abundant if the sum of its divisors (excluding the number itself) is greater than the number, e.g. 12. A number is deficient if it is neither perfect nor abundant.

    3) Write a function, which accepts three arrays (integer type), two of these arrays contain sorted data which must be merged and placed in the third array. Assume that the third array contains enough empty locations to hold the data of both arrays.

    4) Write a function which given an array of characters and the size of the array Max returns TRUE if the characters in the array form a palindrome (the same word spelt backwards and forwards, e.g. CIVIC) and FALSE otherwise.


    5) Write a function, which accepts a number, Num and determines whether the number is prime or not.

    6) Alex became bored one day and to break the monotony, he carried out an experiment with a row of mailboxes. These mailboxes were numbered 1 through 150 and beginning with mailbox 2, he opened the doors of all even-numbered mailboxes. Next beginning with mailbox 3, he went to every third mailbox, opening its door if it was closed and closing it if it was open. Then he repeated this procedure with every fourth mailbox, then every fifth mailbox, and so on. When he was finished he was surprised at the distribution of closed mailboxes. Write a program to determine which ones these were.

    7) Write a function, which accepts an array and the number of items in the array and returns the location of the largest item in the array.

    8) Write a function, which accepts an array and the number of items in the array and returns the largest item in an array.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I think I speak for all of us when I say: "Um, no. Do your own homework."

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Sayeh
    Guest
    You know, if you actually approach your teacher after class and say "Teacher, I don't know how to approach this... Can you help me?" they will think you are wiser and be very happy to help you.

    Do not be afraid to ask questions now, while you are young. It is really the only time you have where you get to ask as many questions as you like, no matter how "lame" they may seem-- and it's alright.

    When you get older, you are expected to have the answers.

    And if you are worried about peer pressure-- don't be. 5 years after you graduate, you won't even remember most of their names.

    The only _fool_ is the one who DOESN'T ask questions when they need to...

    Don't become a fool.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    ...a dying programmer...
    "I...I know the answer to all eight questions. I am weak but I will tell you the answers now. Ugh... (dies)"

    Seriously, though. What have you written on your own? If you can't tackle any of it then why are you taking such a difficult course?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    2

    Thumbs up thanx

    Hey guys, Thanx for all the advice and stuff....But i end up doing all of them on my own. I was just looking for the "easy way out".
    It was 40% of my course mark...so i had to end up doing it!

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    4

    Thumbs up I Got You Covered on The Triangle

    #include<stdio.h>
    #include<math.h>

    void get_data(int *s1, int*s2, int*s3);
    char determine_type(int s1, int s2, int s3);
    void display_results(int s1, int s2, int s3, char);

    int main (void)

    {
    int s1, s2, s3;
    char type;
    get_data(&s1, &s2, &s3);
    type = determine_type)s1, s2, s3);
    display_results(s1, s2, s3, type);
    return0;
    /********
    * Input *
    ********/
    void get_data (int *s1, int *s2, int *3)
    {
    printf ("Enter the lenght of side 1:");
    *s1 = get_int();
    printf ("Enter the length of side 2:");
    *s2 = get_int();
    printf ("Enter the lenght of side 3:");
    *s3 = get_int();
    }
    /*Calculations*/
    char determine_type(int s1, int s2, int s3)
    {
    char ret_val 'R'; /*Right Triangle*/
    if ((s1*s1) + (s2*s2) == (s3*s3)&& (s3*s3)-(s1*s1) == (s2*s2)&&
    (s3*s3) - (s2*s2) == (s1*s1))
    {
    ret_val = 'R';
    }
    else if
    ret_val = 'N'
    {
    return ret_val;
    }
    void display_results(int s1, int s2, int s3, char type)
    {
    printf("The three sides %d. %d and %d\n", s1,s2,s3);
    printf("DO NOT FORM A TRIANGLE.\n");
    }
    }
    else
    {
    switch (type)
    {
    case 'R':
    printf("Forms a Right Triangle.\n");
    break;

    default:
    }
    Hope this helps

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  2. How come Dev C++ cant run some programs??
    By Sephiroth in forum C Programming
    Replies: 41
    Last Post: 09-17-2005, 05:35 AM
  3. Way to get the current open programs displayed?
    By CPPguy1111 in forum C++ Programming
    Replies: 6
    Last Post: 06-22-2005, 12:24 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM