Question

Briefly explain what is wrong (exactly 1 error) with the following code. int num_cmb = rand()...

Briefly explain what is wrong (exactly 1 error) with the following code. int num_cmb = rand() % 6; // # of combinations int num_pmt = ( num_cmb + 1 ) % 10; // # of permutations cout << num_num_cmb; cout << num_num_pmt; double num_arng, num_drng; // # of arrangements, derangements num_arng = 2.0 / ( 1 + num_cmb - ( 1 + num_cmb ) ); num_drng = 1.5 * num_pmt; cout << num_arng; cout << num_drng;  

Homework Answers

Answer #1

//C++ Solution

int num_cmb = rand() % 6; // # of combinations
   int num_pmt = ( num_cmb + 1 ) % 10; // # of permutations
   cout << num_num_cmb;/*ERROR=> num_num_cmb was not defined. it should be num_cmb*/
   cout << num_num_pmt;/*ERROR=> num_num_pmt was not defined. It should be num_pmt */

   double num_arng, num_drng; // # of arrangements, derangements
   num_arng = 2.0 / ( 1 + num_cmb - ( 1 + num_cmb ) );
   num_drng = 1.5 * num_pmt;
   cout << num_arng;
   cout << num_drng;

//If you need any help regarding this solution....... please leave a comment...... thanks

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
what is the output from the following code? int number=10; int* ptr = &number; number+=10; cout<<*ptr;
what is the output from the following code? int number=10; int* ptr = &number; number+=10; cout<<*ptr;
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
IN C++ VERY EASY What's wrong with this code? The following function prints a reverse half-pyramid...
IN C++ VERY EASY What's wrong with this code? The following function prints a reverse half-pyramid populated by the alternating dots and stars (see example below). The odd rows contain stars and even rows contain dots. Debug the code to fix all the compilation and run-time errors, so that the code generates the desired output. For instance, when the 'n' value passed to the function is 6, the output would look like the following. ****** ..... **** ... ** ....
Please find the errors of the following code a) int x[5]; int k = 10; for...
Please find the errors of the following code a) int x[5]; int k = 10; for (k = 0; k <= 5; k++) { x[k] = k -1; } b) int x[5]; for (k = 1; k <= 5; k++) { cout << x[k-1] << endl; } c) int x[5]={1,2,3,4,5}, y[5]; y = x; for (k = 0; k < 5; k++) { cout << y[k] << endl; } d) int size; cin >> size; int myArr[size];
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark them in the code and explain the reason briefly in place. #include<iostream> using namespace std; int main() { cout<<”Please input the radius (in integer): ”>>endl; int 1var = 10, var=20; double area = 40; cin<< var; //get an input of the radius and store in var float continue; float const pi = 2.64; pi += 0.5; do { cout<<”The radius is ”<<”var”<<endl; //print the...
What is wrong with this code snippet? Explain why it is wrong. Fix it public abstract...
What is wrong with this code snippet? Explain why it is wrong. Fix it public abstract class Clock { public DateTime GetTime() { return DateTime.Now; } } public abstract class Radio { public void SetStation(double freq) { } public void PlayRadio() { } } public class AlarmClock : Clock, Radio { public void SetAlarm(DateTime time) { } public void SnoozeAlarm() { } }
what am i doing wrong here ? starting out with c++ early objects 9th edition chapter...
what am i doing wrong here ? starting out with c++ early objects 9th edition chapter 10 programming challenge 6 #include <iostream> using namespace std; int main() {       double findMedian(int* numbers, int size) {    double median;    if (size % 2 == 0)        median = (double)(*(numbers + ((size - 1) / 2))            + *(numbers + (((size - 1))) / 2;    else                median = *(numbers + ((size -...
C++ What is the value of average after the following code executes? double average; average =...
C++ What is the value of average after the following code executes? double average; average = 4.0 + 3.0 * 2.0 + 1.0; Consider the following function: int compute(int n) { int x = 1; for (int i = 1; i <= n; i++) { x *= i; } return x; } What is the returned value for the following function call? int value = compute(4); What is the value of number after the following statements execute? int number; number...
What will the following 2 Arduino code print on the serial monitor?   int x =1 ;...
What will the following 2 Arduino code print on the serial monitor?   int x =1 ; void setup() {        Serial.begin(9600);   }    void loop() {        Serial.println(x);   x = x+1; }        And int x =1 ; void setup() {        Serial.begin(9600);   }    void loop() {    if (x < 10) {    Serial.println(x);   x = x+1; } else {   Serial.println(x);   } }