Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

codes

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
0
tsburt
Asked:
tsburt
  • 2
1 Solution
 
fridomCommented:
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?

Friedrich
0
 
tsburtAuthor Commented:
well just started not sure how to start....
i got this so far.

#include <stdlib.h>
#include<iostream.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 ?
0
 
fridomCommented:
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
Regards
Friedrich
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now