Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.14, Problem 2.23CP
What is wrong with the following
#include <iostream>
using namespace std;
int main()
{
number = 62.7;
double number;
cout ≪ number ≪ endl;
return 0;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The language we are using here is in Racket.
Please enter the following code:
(cond ((equal? 16 3) (+ 3 8))
((equal? 16 8) 12)
(else (* 6 3)))
Write the return value for the above code. If replacing all of the 16's in the above code with 8, what is the return value? What about replacing the 16’s with 3? What does the cond function do?
Why won't this code run in C++? #include<iostream>#include<stdlib>void main(){int A,B,i,sum=0;cout<<endl<<"Enter any two even numbers: ";cin>>A>>B;if(A%2==1||B%2==1) // checking whether given numbers are even or not{cout<<"Invalid input: Enter only even numbers"<<endl;exit(1);}else if(A>B) // checking whether A is greater than B or not{cout<<"Invalid input: First number A must be smaller than Second number B"<<endl;exit(1);}else{for(i=A;i<=B;i++){if(i%2==0) // checking for even number{sum=sum+(i*i);}}}cout<<"Sum of even numbers between "<<A<<" and "<<B<<" is "<<sum<<endl;}
What is the value of the variable sum once the following C code has been executed?
#define N = 5int a[] = {1,2,3,4,5}p = &a[0];
while (p < &a[N]) sum += *(p++);
Chapter 2 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 2.1 - The following C++ program will not compile because...Ch. 2.3 - The following C++ program will not compile because...Ch. 2.3 - Study the following program and show what it will...Ch. 2.3 - Write a program that will display your name on the...Ch. 2.4 - Prob. 2.5CPCh. 2.4 - What will the following program display on the...Ch. 2.6 - Which of the following are illegal variable names,...Ch. 2.6 - Prob. 2.8CPCh. 2.6 - Prob. 2.9CPCh. 2.6 - Prob. 2.10CP
Ch. 2.7 - Prob. 2.11CPCh. 2.7 - Which of the following is a character literal? B BCh. 2.7 - Prob. 2.13CPCh. 2.7 - Write a program that has the following character...Ch. 2.7 - What is wrong with the following program...Ch. 2.7 - Prob. 2.16CPCh. 2.7 - Write a program that stores your name, address,...Ch. 2.11 - Prob. 2.18CPCh. 2.11 - Prob. 2.19CPCh. 2.11 - Prob. 2.20CPCh. 2.14 - Is the following assignment statement valid or...Ch. 2.14 - How would you consolidate the following...Ch. 2.14 - What is wrong with the following program? How...Ch. 2.14 - Prob. 2.24CPCh. 2.16 - Prob. 2.25CPCh. 2 - How many operands does each of the following types...Ch. 2 - How may the double variables temp, weight, and age...Ch. 2 - Prob. 3RQECh. 2 - Write assignment statements that perform the...Ch. 2 - Is the following comment written using single-line...Ch. 2 - Is the following comment written using single-line...Ch. 2 - Modify the following program so it prints two...Ch. 2 - What will the following programs print on the...Ch. 2 - Multiple Choice 9. Every complete statement ends...Ch. 2 - Prob. 10RQECh. 2 - Every C++ program must have a ________. A) cout...Ch. 2 - Preprocessor directives begin with ________. A) #...Ch. 2 - The following data 72 'A' Hello World" 2.8712 are...Ch. 2 - A group of statements, such as the contents of a...Ch. 2 - Which of the following are not valid assignment...Ch. 2 - Which of the following are not valid cout...Ch. 2 - Assume w = 5, x = 4, y = 8, and z = 2. What value...Ch. 2 - How would each of the following numbers be...Ch. 2 - The negation operator is ________. A) unary B)...Ch. 2 - A(n) ___________ is like a variable, but its value...Ch. 2 - Prob. 21RQECh. 2 - T F A variable must be defined before it can be...Ch. 2 - T F Variable names may begin with a number.Ch. 2 - T F Variable names may be up to 31 characters...Ch. 2 - T F A left brace in a C++ program should always be...Ch. 2 - T F You cannot initialize a named constant that is...Ch. 2 - Prob. 27RQECh. 2 - Convert the following pseudocode to C++ code. Be...Ch. 2 - There are a number of syntax errors in the...Ch. 2 - Sum of Two Numbers Write a program that stores the...Ch. 2 - Sales Prediction The East Coast sales division of...Ch. 2 - Sales Tax Write a program that will compute the...Ch. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Average of Values To get the average of a series...Ch. 2 - Annual Pay Suppose an employee gets paid every two...Ch. 2 - Ocean Levels Assuming the oceans level is...Ch. 2 - Total Purchase A customer in a store is purchasing...Ch. 2 - Cyborg Data Type Sizes You have been given a job...Ch. 2 - Miles per Gallon A car holds 15 gallons of...Ch. 2 - Distance per Tank of Gas A car with a 20-gallon...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Circuit Board Price An electronics company sells...Ch. 2 - Prob. 14PCCh. 2 - Triangle Pattern Write a program that displays the...Ch. 2 - Diamond Pattern Write a program that displays the...Ch. 2 - Stock Commission Kathryn bought 750 shares of...Ch. 2 - Energy Drink Consumption A soft drink company...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Suppose you write a program that is supposed to compute the interest on a bank account at a bank that computes ...
Problem Solving with C++ (10th Edition)
Consider a class characteristic that will be used in an online dating service to assess how compatible two peop...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Draw state diagrams of the control software for: an automatic washing machine that has different programs for d...
Software Engineering (10th Edition)
LandTract Class Make a LandTract class that has two fields: one for the tracts length and one for the width. Th...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I am having trouble making this code work in C++. int main() {int songNum; songNum = 5;cout << "num:" << songNum << endl;cout << songNum << endl;cout << songNum "songs" << endl;/* Your solution goes here */ return 0;arrow_forwardWhat is wrong with the following program? How would you correct it? #include using namespace std; int main() { number = 62.7; double number; cout << number << endl; return 0; }arrow_forwarda) What is the risk of using strcpy() in C given the code below? void f1(char *str2) { int y; char str1[10]; strcpy(str1, str2);arrow_forward
- 8. What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 5; float b; cout << sizeof(++a + b); cout << a; return 0; }arrow_forwardWhat is the output of the following C++ code? #include<iostream>using namespace std;int x = 1;int main(){int x = 2;{int x = 3;cout << ::x << endl;}return 0;}arrow_forwardWhat will be the output of the following C++ code? #include <iostream>using namespace std;int main(){int a = 5, b = 6, c, d;c = a, b;d = (a, b);cout << c << ' ' << d;return 0;}a) 5 6b) 6 5c) 6 7d) 6 8arrow_forward
- What will be the output of the following C code? #include int main() { int i = -3; int k = i % 2; printf("%d\n", k); return 0; }arrow_forwardIn C++: Examine the code segment. What will be printed? If there are any errors indicate the nature of each error. int a[7] = {31, 12, 32, 14, 25, 16, 27}; int *ptr; ptr = & a[2]; for ( i=1; i<=5; i=i+2) cout << *(ptr +i); cout << a[0] << *ptr << *ptr - 2 << *(ptr -1)) << endl;arrow_forward3. What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { float num1 = 1.1; double num2 = 1.1; if (num1 == num2) cout << "Canada"; else cout << "US"; return 0; }arrow_forward
- What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int i, j; j = 10; i = (j++, j + 100, 999 + j); cout << i; return 0; } a) 1000 b) 11 c) 1010 d) 1001arrow_forwardwhat is the output of the following c++ statement: int a, b, c, d; a = 5; b = 4; c = (++b + a--); cout << a << " " << b << " " << c << endl;arrow_forwardWhat will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int const p = 5; cout << ++p; return 0; } a) 5 b) 6 c) Error d) 8arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY