Questions: 11 448

Answers by our Experts: 10 707

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 & Filtering

write a program that calculates and prints the sum of the even integers from 2 to user defined limit and product of odd integers from 1 to user defined limit. use a do-while loop that ask the user whether the program should be terminated or not also maintain a count as to how many times the user ran to do-while loop

write a program that calculates and prints the sum of the even integers from 2 to user defined limit and product of odd integers from 1 to user defined limit. use a do-while loop that ask the user whether the program should be terminated or not also maintain a count as to how many times the user ran to do-while loop

write a program that calculates and prints the sum of the even integers from 2 to user defined limit and product of odd integers from 1 to user defined limit. use a do-while loop that ask the user whether the program should be terminated or not also maintain a count as to how many times the user ran to do-while loop


  1. In the code editor, you are provided with a main() function that asks the user for two integers and calls the slowDisplay() function.
  2. This slowDisplay() function is a recursive function which should perform the functionality explained in the problem description above.
  3. This function is only partially implemented as it lacks a base case. Your task is to add the base case needed by this recursive function.

Example:

Starting num = 2

Next num = 3

It should then print 3 4 5


Given code:

#include <iostream>

using namespace std;


void slowDisplay(int, int);


int main(void) {

  int start, nextCount;


  cout << "Enter starting integer: ";

  cin >> start;


  cout << "Enter how many next integers: ";

  cin >> nextCount;


  slowDisplay(start + 1, nextCount);


  return 0;

}


void slowDisplay(int start, int nextCount) {

  // TODO: Add the base case here

  if(start == 0) {

    

    cout << start << " ";

    slowDisplay(start + 1, nextCount - 1);

  }

}



  1. In the code editor, you are provided with a main() function that asks the user for a string and passes this string and the size of this string to a function call of the function, preserveString().
  2. This preserveString() function has already been partially implemented. Your only task is to add the recursive case of this function.

To do: Print the string repeatedly, each time it prints the string, exclude the last letter until only 1 letter is left.


Given code:

#include <iostream>

#include <cstring>

using namespace std;


#define STR_MAX_SIZE 100


void preserveString(char*, int);


int main(void) {

  char str[STR_MAX_SIZE];


  cout << "Enter string: ";

  fgets(str, STR_MAX_SIZE, stdin);


  preserveString(str, strlen(str));


  return 0;

}


void preserveString(char *str, int size) {

  if(size > 0) {

    for(int i = 0; i < size - 1; i++) {

      cout << str[i];

    }

    cout << endl;


    // TODO: Add the recursive case of the function here

  }

}



#include <iostream>




ung namespace std;




#include <string> class snident




string name="DefaultName":




string birthyear= "9999":




Your Code Here




int main(){




sident $1;




student $2("Geoffrey Hinton"); student $3("Yann LeCun", "1960");




s1.print_info(); print_info();




$3.print_info():




$2.change year(1947");




s1 change_name("YourName");




s1.change year("YourBirth Year>");




$2.print info(); $1.print_info();




return 0;




Complete the student class so the main function above produces the following output:




Name: DefaultName, Birth Year: 9999




Name: Geoffrey Hinton, Birth Year: 9999.




Name: Yann LeCun, Birth Year: 1960 Name: Geoffrey Hinton, Birth Year: 1947.




Name: YourName, Birth Year: <Your Birth Year>

getsize return the size of collection


getsize return the size of collection


Write one dimensional array java program that ask to the user to enter the array



size and reads n integers, compute their average, and find out how many



numbers are above the average. Your program first enter the array size and reads



the numbers and computes their average, then compares each number with the



average to determine whether it is above the average.



Sample Input/Output:



How many numbers do you have?6



Enter a value for array [1]:100



Enter a value for array [2]:10



Enter a value for array [3]:1000



Enter a value for array [4]: 500



Enter a value for array [5]: 200



Enter a value for array [6]: 77



List of elements: 100 10 1000 500 200 77



The sum of the 6 elements: 1887.00



The average of the 5 elements: 314.50



Numbers above average: 4




Write a program that approximate e using a loop that terminates the difference between the two successive values of e is less than 0.0000001

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS