Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS 141 Computer Programming 1 Branching Statements 2 Question #1 Question Find the errors and correct them.. a. If x<0 cout<<x<<"is negative"; b. If(x=2) y++;else; if(x=3) y+=2; 3 Question #1 Answer a. If x<0 cout<<x<<"is negative"; If (x<0) cout<<x<<"is negative"; b. If(x=2) y++;else; if(x=3) y+=2; if(x==2)y++; else if (x==3)y+=2; 4 Question #2 Question Modify the following code to produce the output shown. Use proper indentation techniques. You must not make any changes other than inserting braces Question #2 Question 5 Question #2 Question 6 Assuming x=5 and y=8, the following output is produced. Question #2 Answer 7 Question #2 Question 8 Assuming x=5 and y=7, the following output is produced. Question #2 Answer 9 10 Problems 11 Problem #1 Question Write a program that asks the user to input his age and outputs whether he is older, younger or the same age as you. Problem #1 Answer 12 13 Problem #2 Question Write a program that determines the maximum and the minimum of three numbers. Problem #2 Answer 14 Problem #3 15 Question Write a program that checks the order of a medicine from a pharmacy store. The program should read the order quantity and the medicine quantity in the store. When the order quantity is more than the store quantity, your program should display the message “No enough quantity”. When the order quantity is less than the store quantity, you have to check that the order quantity must be not more than 16 except there is more than 40 items in the store. The messages that will be displayed in that cases are “Your order is accepted” OR “You cannot order more than 16 item” 16 Problem #3 Question Problem #3 Answer 17 Problem #4 18 Question Write a program that calculates the areas of different shapes according to a character input signifying the shape: c for circle. r for rectangle. s for square. t for triangle. The necessary input should be read after the character. Hint: use case Problem #4 Answer 19 Problem #5 20 Question Write a program to simulate a simple calculator. It should ask the user to enter a first number, the operation(as a character), and the second number. Addition, Subtraction, Division, Multiplication, and Modulus are the basic operations that should be implemented .(HINT: use case). Enter a mathematical Expression:2+4 The result is:2+4=6 Problem #5 Answer 21 Problem #5 output 22 23 EVALUATION !! Hadeel Al-Ateeq 24 Problem #1 Question Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered by the user. A triangle is valid if the sum of all the three angles is equal to 180 degrees. Problem #1 Answer 25