C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a C++ program that reads a sequence of integer numbers from the input file data.txt. The sequence ends with a sentinel value of zero. The program should output the following into an output file results.txt

  1. the count of all positive numbers.
  2. the count of all negative numbers.
  3. the sum of the positive numbers.
  4. the sum of the negative numbers.
  5. the maximum of negative numbers and
  6. the minimum of positive numbers.

Use the following values in the file data.txt to test your program:

5

4

-8

-7

6

-2

9



Write a C++ program that prompts the user to enter an even integer N which represents how many numbers he/she wants to enter. The program then reads N decimal numbers and finds the minimum number in the first half and the maximum number in the second half.


Complete the declaration and initialization of the array variable with datatype character, char array[ ]=???;. Initialized the first index with A, the second index with T, the third index E, the fourth index N, the fifth index as E, and the sixth index as O.


Your answer's format should be a complete declaration at the same time initialization:

format: datatype array_name[ ]=???;



Answer:

1.     Create a menu to execute tasks. There shall be n tasks in total, update as they comes up. You should properly prompt wherever necessary.


  1. What is the last index for an array declared and initialized as int numbers[ ] = {1,2,3,4,5,6};?
  2. What is the value of index three (3) for an array declared and initialized as int numbers[ ]={1,2,3,4,5,6};?
  3. What is the value of index two (2) for an array declared and initialized as char version = "Monterey"?
  4. What is the last index for an array declared and initialized as char version = "Monterey"?

Let us assume the program below runs smoothly, identify all function arguments in each function call in exact order and separate each argument in just a comma:


int getCube(int number){ return number * number * number;}

char getLetter(double n) {if(n>50) {return'0';} return 'X'}

double getThis(int num){return 1.0;}

int main(){

    int n1 = 10, n2 = 123;

    double vall = 123.45, val2 = 456.234;

cout << getCube(10) << " " << getCube(123) << "\n";

  cout << getLetter(val2) << "-" << getLetter(val1);

    cout << getLetter(34.23) << "--" << getThis(88);

  cout << getThis(val1);


    return 0;

}



What is the Answer? :


Let us assume the program below runs smoothly, identify all function arguments in each function call in exact order and separate each argument in just a comma:


int getCube(int number){ return number * number * number;}

char getLetter(double n) {if(n>50) {return'0';} return 'X'}

double getThis(int num){return 1.0;}

int main(){

    int n1 = 78, n2 = 55;

    double vall = 123.56, val2 = 784.59;

    cout << getLetter(val1) << "-" << getLetter(val1);

    cout << getLetter(val2) << "--" << getThis(val2);

    cout << getCube(123) " " << getCube(321) << "\n";

    cout << getThis(val1);


    return 0;

}




What is Answer:


1.     Write C++ statements that prompt the user to enter a person’s last name and then store the last name into the variable name.


1. Create a new project with following particulars

1.      name the project title in the following format “ID_section_lab#” e.g., “f2019065111_w1_lab2”.

2.      Create a menu to execute tasks. There shall be n tasks in total, update as they comes up. You should properly prompt wherever necessary. A sample menu is shown below.


1.     Write a program that prompts the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven. The program outputs the number of miles the automobile can be driven without refueling.


LATEST TUTORIALS
APPROVED BY CLIENTS