What is the output of the following cout statements embedded in these if-else statements? You are to assume that these are embedded in a complete correct program. Explain your answer.
a. if (0)
cout << “0 is true”;
else
cout << “0 is false”;
cout << endl;
b. if (1)
cout << “1 is true”;
else
cout << “1 is false”;
cout << endl;
c. if (–1)
cout << “–1 is true”;
else
cout << “–1 is false”;
cout << endl;
Note: This is an exercise only. This is not intended to illustrate
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Programming in C
Java: An Introduction to Problem Solving and Programming (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Concepts Of Programming Languages
- Compute the weakest preconditions of the following statements for the given postconditions. Assume all variables are integers1)a = 2*b + 1;b = a*a + 1;{ a > 10 } 2)if (b > 0)a = 4*b - 10;elsea = b + 172;{ a > 0 }arrow_forwardNeed a help with this programs for each of the following problem statements: - use of comment statements- use of descriptive variable names 1. (gcount) A program that will accept any number of grades foran exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1for a D, and 0 for an F. After all grades have been entered, allow theuser to enter -1 to exit. Output the number of grades in each category. - correct use of array of counters - correct use of loop - correct outputarrow_forwardConsider the following program:int x = 1, y = 1; co <x=x+y;>|| y=0; ||x=x-y; oc(a) Does the program meet the requirements of the At-Most-Once Property (2.2)? Explain.(b) What are the final values of × and y? Explain your answer.arrow_forward
- Consider the following statements. Rewrite each logical statement using the corresponding English sen- tences. please help and do all of them with work pleasearrow_forwardWrite the following compound statement in terms of the simple statements p, q, and r. "I go to office hours and ask questions, and my professor does not remember me." p: I go to office hours. q: I ask questions. r: My professor remembers me.arrow_forwardSuppose savings and expenses are variables of type double that have beengiven values. Write an if-else statement that outputs the word "Solvent",decreases the value of savings by the value of expenses, and sets the value ofexpenses to zero, provided that savings is larger than expenses. If, however,savings is less than or equal to expenses, the if-else statement should simplyoutput the word "Bankrupt" without changing the value of any variables.arrow_forward
- State what output, if any, results from each of the following statements: a. for (i = 1; i <= 1; i++)cout << "*";cout << endl;b. for (i = 2; i >= 1; i++)cout << "*";cout << endl; c. for (i = 1; i <= 1; i--)cout << "*";cout << endl;d. for (i = 12; i >= 9; i--)cout << "*";cout << endl;e. for (i = 0; i <= 5; i++)cout << "*";cout << endl;f. for (i = 1; i <= 5; i++){cout << "*";i = i 1 1;}cout << endl;arrow_forwardWrite the following statements in terms of ?, ?, ?, and logical connectives:a. Either 4 > 1 or 4 < 5.b. If 3 ≤ 3 , then 2 > 2. c. It is not the case that 2 > 2 or 4 > 1arrow_forwardHow do you find the weakest precondition for the conditional statements below? if (x < 7) x = x*x; else x = x+1; { x >= 11 } if (x != 0) z = x; else z = x+1;arrow_forward
- What is wrong with the following condition? Correct it. if (grade > 70 || grade <= 80) JAVA PROGRAMMINGarrow_forwardWrite a C++ program that : You have to do the following question only by nested if-statement. FROM GRADE A TO F A 93-100% 4.00 A- 90-92% 3.70 B+ 87-89% 3.30 B 83-86% 3.00 B- 80-82% 2.70 C+ 77-79% 2.30 C 73-76% 2.00 C- 70-72% 1.70 D+ 67-69% 1.30 D 63-66% 1.00 D- 60-62% 0.70 F Ask user to enter a grade and then determine the letter grade. Sample output: What is your grade: 94 Your grade on your trascript would be A.arrow_forwardAnswer this question, also show how you have solved it. Use De Morgan’s laws to write negation for the following statement: a. The dollar is at an all-time high and the stock market is at a record low. b. This computer program has a logical error in the first ten lines or it is being run with an incomplete data set .arrow_forward
- 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