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
- 2. Write a program that determines a student's grade. The program will read three scores and determine the grade based on the following rules: -if the average score >=90% and grade=A -if the average score >= 70% and grade=B -if the average score>=50% and grade=C -if the average scoregrade=Farrow_forwardQ3, A lecturer intends to separate his students into 2 groups based on their INDEX Numbers, those with odd numbers in group A and EVEN numbers in B. Use if-else statement to implement this. Q4.Your son intends to randomly mention some numbers to you, write a program using While or do-whileloop that will print all the numbers and the sum of the positive numbers.arrow_forwardQuestion 4 The correct statements are: L {E} = {E}L = L. LØ = ØL = Ø. OL₁= (a, b) and L₂ = {a, c}. Then L₁ L2 = {aa, ac, ba, bc}.arrow_forward
- .arrow_forwardAnswer the following question based on the given statement. "Calculation of electricity meter reading for domestic usage at a rate of RMO.25 per kWh." Write a complete C program that permits interaction with user in this manner. Example of output: Enter previous meter reading: 5635 Enter current meter: 5777 You have used (kWh): 142 Your total payment (RM): 35.50arrow_forwardYou are required to write a C++ program to determine the number of students based ontheir weight range. First, the user must input the total number of students in the class. Next,by using looping, the user need to input the weight, in kilogram (kg), for each of thestudents. The program should display error message if the user input invalid weight. Theprogram should produce the output according to the following format: Range(kg) Number of StudentsBelow 40 ?41 – 60 ?61 – 80 ?81 – 100 ?Above 100 ?arrow_forward
- How do I use PYTHON to create a high/low number guessing game? Assignment reads: If the user’s guess is higherthan the randomly chosen number, the program should say “Your guess was too high” and prompt theuser to guess another number. If the user’s guess was lower than the randomly chosen number, theprogram should say “Your guess was too low” and prompt the user to guess another number. Finally, ifthe user guesses correctly, the program should say the user’s guess was correct and tell the user howmany guesses it took them to get the numberarrow_forwardHow do I program this in the C language I can't seem to get the looping aspect while holding the valuesarrow_forwardProblem: Write a program for computing the amount of money in a bank account at the end of each quarter for a period of one year. A quarter is equivalent to 3 months. Assume that the account is created at the beginning of a year (i.e. January 1). The year will be entered at run time through the keyboard. The account has an initial principal that is entered at run time through the keyboard. No deposit or withdrawal is made within the one-year period. The interest is compounded quarterly which means that the interest earned for the first quarter will form part of the principal for the second quarter, the interest earned for the second quarter will form part of the principal for the third quarter and so on. The annual interest rate is 5%. The interest rate for a quarter is computed by dividing the annual interest rate by 4 since there are four quarters in a year. The computational procedure (see algorithm) and the output of the program (see sample run) are shown below. The output includes…arrow_forward
- Can you write in C++arrow_forwardNote: Please answer in C++ Programming language. During Eid, it is a tradition for every father to give his children money to spend on entertainment. Chef has N coins; denote the value of the coin i by vi. Since today is Eid, Chef gives one coin to each of his two children. He wants the absolute value of the difference between the values of the coins given to the two children to be as small as possible to be as fair as possible. Help the chef by telling him the minimum possible difference between the values of the coins given to the two children. Of course, the chef cannot give the same coin to both children. Possible input 1 3 142 Required Output 1arrow_forwardPlease answer in matlab code.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