NOTE: I have completed answer for your question. Please check
and let me know if you have any queries. I will get back to you
within 24 hours. Thanks for your patience.
Q5)
Output:-
0.8 12 Bill
Explanation:
1) In the first case, when input is 12.5, Bill and 15. Since we are
taking integer value first followed by double value then
string.
2) Since we are reading double value as integer it takes the number
as 0.8. whereas for double value it reads as 12 and string is read
into name.
Q6)
Output:-
12.8Bill15
Explanation:
1) In the second case x which is double reads as 12.5, name
variable as Bill and integer value as 15.
2) While printing we did not give any space. Hence it prints the
values without any space.
Q7)
Output:-
12.8 0
Explanation:
1) In the third case when we give input as 12.5 bill and 15.
2) The x only contains 12.8 and y as 0 whereas name as empty
because bill string is read into y.
Given the input (15 marks) 12.8 Bill 15 and the variable declaration: double x = 0;...
Need help with a C++ program. I have been getting the error "this function or variable may be unsafe" as well as one that says I must "return a value" any help we be greatly appreciated. I have been working on this project for about 2 hours. #include <iostream> #include <string> using namespace std; int average(int a[]) { // average function , declaring variable int i; char str[40]; float avg = 0; // iterating in...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...
I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...
How to turn this file into a main.cpp, a header which contains the function declaration, and a implementation fiel containing the function definition ? #include<iostream> #include<string> #include<iomanip> using namespace std; #define NUM 1 #define MULT 4 void getPi(int iter); int main() { int it; cout << "Enter the number of iterations needed to find PI: "; cin >> it; while (it < 1) { cout << "Error!!! Iteration input should be positive." << endl;...
4. Using cin, Allocating Memory, and Writing Assignment Statements cin, Memory Allocation, and Assignment Statements show the variable name and value of each statement 19. double x = 5.0; int y = 4; x= x + y 14; 20. double x = 5.0; int y = 4; y = x + y/4; 21. int count = 0; cout << ++count << endl; cout << count++ << endl; cout << count << endl;
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...
Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...
The output should be "The distance is 0" (The expected). ==================== YOUR OUTPUT ===================== 0001: Enter~the~x~coordinate~for~point~1:~0 0002: Enter~the~y~coordinate~for~point~1:~0 0003: Enter~the~x~coordinate~for~point~2:~0 0004: Enter~the~y~coordinate~for~point~2:~0 0005: The~distance~is~-nan =================== MISMATCH FOUND ON LINE 0005: =================== ACTUAL : The~distance~is~-nan EXPECTED: The~distance~is~0 ====================================================== #include <iostream> #include <iomanip> #include <string> using namespace std; float squareRoot(float s) { float xn; xn = s / 2.0; int counter = 1; while (counter <= 10) { xn = (xn + (s/xn))/2.0; counter = counter + 1; } return xn; } int...
Given the following function: int fun1(int count){ int Num ; for (i = 0; i < count; ++i) { cin >> Value; if (i == 0) Num = Value; else if (Value > Num) Num = Value; } return Num ; } What is the output of the following C++ code segment if the following list is entered? (Input list: 5 -15 -90 -2 -60 -30) int Num = 0 , Value, numValues; cin >> numValues; if (numValues > 0) cout...