Posted on 2007-10-11
Last Modified: 2010-04-15
hey guys i'm having a problem on how to start this problem.. i basically just started taking this C class and having problems doing these codes. i appreciate the help

Write a program to do the following:
- obtain two random numbers from the rand() function
- place the random numbers in variables 'a' and 'b'
- set an integer variable 'bigger' so it is the highest value of 'a' and 'b'
- set an integer variable 'smaller' so it is the lowest value of 'a' and ''b'
- obtain values in integer 'c' by executing statements with each of the expressions listed below
- obtain values in float 'x' by executing statements with each of the expressions listed below
- for each expression: print on a new line text with the statement number and the value obtained
1. c = bigger/smaller
2. c = smaller/bigger
3. c = bigger%smaller
4. c = smaller%bigger
5. c = bigger++
6. c = -smaller++
7. c = bigger>smaller
8. c = ( smaller== 3 )
9. c = (( smaller + 3) && bigger )
10. x = bigger/smaller
11. x = smaller/bigger
12. x = (float) bigger/smaller
13. x = (float) (bigger/smaller)
14. x = (float)(smaller/bigger)
15. x = (float) bigger / (float)smaller
Question by:tsburt
    LVL 24

    Expert Comment

    I posted to you other question. And as you know you should at least start yourself.  what can't be that hard to follow the instrctions?
    a = random();
    b = random();

    What is that difficult about that:
    Now how difficult can ot be to find the maximum of two numbers?

    and what can be that difficult to write
     c= bigger/smaller if you know what you had to write?

    LVL 1

    Author Comment

    well just started not sure how to start....
    i got this so far.

    #include <stdlib.h>

      int main(void);
          a = rand();
          b = rand();
          if (a>b)

    bigger = a; else bigger = b
    bigger=b && smaller=a;
    c = bigger/smallercout << c << endl;
    c = smaller/biggercout << c << endl;
    c = bigger%smallercout << c << endl;
    c = smaller%biggercout << c << endl;
    c = bigger++cout << c << endl;
    c = -smaller++cout << c << endl;
    c = bigger>smallercout << c << endl;
    c = ( smaller== 3)cout << c << endl;
    c = (( smaller + 3) && bigger )cout << c << endl;
    x = bigger/smallercout << x << endl;
    x = smaller/biggercout << x << endl;
    x = (float) bigger/smallercout << x << endl;
    x = (float) (bigger/smaller)cout << x << endl;
    x = (float)(smaller/bigger)cout << x << endl;
    x = (float) bigger / (float)smallercout << x << endl;

    am i missing something ?
    LVL 24

    Accepted Solution

    iostream.h is totally unkown to C you can use
    #include <stdio.h>

    or you can make up you mind whether you like to learn C or C++.

    The formatting is really bad and the logic is wrong also.
    please write
    if (a > b) {
       bigger = a;
       smaller = b;
    } else {
       bigger = b;
       smaller = a;

    the code below is just not C but I don't know what.

    how about writing simply

    c = biggeer / smaller;
    printf("bigget/smaller result = %d\n", c);

    Yes you are missing quite a lot

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now