Copy the main given below and add what the directions tell you to edit main to Copy
#include<iostream> using namespace std; // Put prototype here int main() { int startValue; int stopValue; int answer; char again; do { cout << "Enter the start value: "; cin >> startValue; cout << "Enter the stop value: "; cin >> stopValue; // Call the function summation (after you write it) // and store the value returned into the variable answer // declared above // You can assume that start value is less than or equal // to stop value // The description of the function is given below // Don't forget to put prototype at top cout << "The summation from " << startValue << " to " << stopValue << " is " << answer << endl; cout << "Do you want to find another summation (y/n): "; cin >> again; } while (again == 'y' || again == 'Y'); return 0; } // Write function called summation. The function will have // 2 formal parameters. The first formal parameter is the start // value and the second formal parameter is the stop value. // You can assume start value is less than or equal to stop value // The method will find the summation from the first value // to the stop value and return the answer // for example, if start value is 2 and stop value is 5, the // program will return the value 14 (2 + 3 + 4 + 5)
Sample Output
Enter the start value: 2 Enter the stop value: 5 The summation from 2 to 5 is 14 Do you want to find another summation (y/n): y Enter the start value: -3 Enter the stop value: 15 The summation from -3 to 15 is 114 Do you want to find another summation (y/n): Y Enter the start value: 3 Enter the stop value: 12 The summation from 3 to 12 is 75 Do you want to find another summation (y/n): n
#include<iostream> using namespace std; int summation(int start, int stop); int main() { int startValue; int stopValue; int answer; char again; do { cout << "Enter the start value: "; cin >> startValue; cout << "Enter the stop value: "; cin >> stopValue; // Call the function summation (after you write it) // and store the value returned into the variable answer // declared above // You can assume that start value is less than or equal // to stop value // The description of the function is given below // Don't forget to put prototype at top answer = summation(startValue, stopValue); cout << "The summation from " << startValue << " to " << stopValue << " is " << answer << endl; cout << "Do you want to find another summation (y/n): "; cin >> again; } while (again == 'y' || again == 'Y'); return 0; } // Write function called summation. The function will have // 2 formal parameters. The first formal parameter is the start // value and the second formal parameter is the stop value. // You can assume start value is less than or equal to stop value // The method will find the summation from the first value // to the stop value and return the answer // for example, if start value is 2 and stop value is 5, the // program will return the value 14 (2 + 3 + 4 + 5) int summation(int start, int stop) { int total = 0; for (int i = start; i <= stop; ++i) { total += i; } return total; }
Copy the main given below and add what the directions tell you to edit main to...
First create the two text file given below. Then complete the
main that is given. There are comments to help you. An output is
also given You can assume that the file has numbers in it
Create this text file: data.txt (remember blank line at end)
Mickey 90
Minnie 85
Goofy 70
Pluto 75
Daisy 63
Donald 80
Create this text file: data0.txt (remember blank line at
end)
PeterPan 18
Wendy 32
Michael 28
John 21
Nana 12
Main
#include...
Fix this code so only the function prototype comes before main. #include <iostream> using namespace std; bool isMultiple(int num1, int num2) { return num1 % num2 == 0; } int main() { char ch = 'Y'; int num1, num2; while(ch =='Y') // While ch is equal to Y { cout << "Enter two numbers(largest first): "; cin >> num1; // Getting 1st number cin >> num2; // Getting 2nd number if(isMultiple(num1, num2)) cout << num2 << " " << "IS...
61. The following program is accepted by the compiler: int sum( int x, int y ) { int result; result = x + y; } T__ F__ 62. The following implementation is accepted by the compiler: void product() { int a; int b; int c; int result; cout << "Enter three integers: "; cin >> a >> b >> c; result = a * b * c; ...
This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...
Lab 6.6 – Using Value and Reference Parameters Below is a copy of the source code. 1 // Lab 6 swapNums.cpp -- Using Value and Reference Parameters 2 // This program uses a function to swap the values in two variables . 3 // PUT YOUR NAME HERE. 4 #include <iostream> 5 using namespace std; 6 7 // Function prototype 8 void swapNums(int, int); 9 10 /***** main *****/ 11 int main() 12 { 13 int num1 = 5, 14...
Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found; string document[1000][6]; ifstream infile; char s[1000];...
In C++ First create the two text file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it Create this text file: data.txt (remember blank line at end) Mickey 90 Minnie 85 Goofy 70 Pluto 75 Daisy 63 Donald 80 Create this text file: data0.txt (remember blank line at end) PeterPan 18 Wendy 32 Michael 28 John 21 Nana 12...
in c++ Finish the methods in the following code. DO NOT CHANGE THE MAIN METHOD. The instructions for each method are in a comment in the template. DO NOT CHANGE THE MAIN METHOD!!!! #include <iostream> #include <string> using namespace std; // prototypes int main() { int answer = 0; int value1 = 0; int value2 = 0; double average = 0; string string1 = ""; int numberVowels = 0; int numberNonVowels = 0; cout << "Enter string1: "; getline(cin, string1);...
c++ Write the following 2 functions and test them. Both of them need to be recursive functions. int sum(int n); // recursive version to calculate the sum of 1 + 2 + ..... + n int str_length(char s[]; // Returns length of the string s[] and the null character, '0\', is not counted in the length). Example of program execution; Enter a positive integer: 10 (user input) The sum of 1+ 2+....+10 is: 55 Enter a sentence: Hello World! (user...
In
c++ programming, can you please edit this program to meet these
requirements:
The program that needs editing:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int cal_avg(char* filenumbers, int n){
int a = 0;
int number[100];
ifstream filein(filenumbers);
if (!filein) {
cout << "Please enter a a correct file to read in the
numbers from";
}
while (!filein.eof()) {
filein >> number[a];
a++;
}
int total = number[0];
for (a = 0; a < n; a++) {...