1 / 31

CS 240 Computer Programming 1

CS 240 Computer Programming 1. Variables. Question 1:. Write the following algebraic expressions as C++ expressions:. b* b – 4*a*c. Question 1:. Write the following algebraic expressions as C++ expressions:. (y*(x*x-y*y)) / (x*x+3*x*y). Question 2-a:.

Télécharger la présentation

CS 240 Computer Programming 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 240Computer Programming 1 Variables

  2. Question 1: Write the following algebraic expressions as C++ expressions: b* b – 4*a*c

  3. Question 1: Write the following algebraic expressions as C++ expressions: (y*(x*x-y*y)) / (x*x+3*x*y)

  4. Question 2-a: Each of the following assignment statement contains at least one error. Identify them:

  5. Question 2-b: Correct the following program so that the output will be 5 . * include <iostream> using namespace std; \\function main begins program execution int main() [ int a=5;b=5;c=1;d==1; result = a+b/c+d; cout << "The Result is " << result << endl; // print result; end line }

  6. Question 2-b: Answer #include<iostream> usingnamespacestd; //function main begins program execution int main() { int a=5; int b=5; int c=1; intd=1; intresult; result = (a+b)/(c+d); cout << "The Result is " << result << endl; // print result; end line return 0; }

  7. Question 3: For the each of the following expressions, give the type and value of its result. Assume the following declarations have been executed before each expression. int x = 2; int y = 5; int z = 6 ; int t = 7; int d = 8;

  8. Question 3: For the each of the following expressions, give the type and value of its result. Assume the following declarations have been executed before each expression. int x = 2; int y = 5; int z = 6 ; int t = 7; int d = 8; ;

  9. Question 3: For the each of the following expressions, give the type and value of its result. Assume the following declarations have been executed before each expression. int x = 2; int y = 5; int z = 6 ; int t = 7; int d = 8;

  10. Question 3: For the each of the following expressions, give the type and value of its result. Assume the following declarations have been executed before each expression. int x = 2; int y = 5; int z = 6 ; int t = 7; int d = 8;

  11. Question 4: Trace the following code to find the value assigned to each variable. Assume that all variables are properly declared as int. X= 20 Y= 15 Z= 6 W= 11 T=4

  12. Question 5: What is the output by each of the following code fragment? The output : 1 2 4

  13. Question 5: What is the output by each of the following code fragment? The output : The Result is :3

  14. Question 5: What is the output by each of the following code fragment? The output : The Cost is 60 The Price is 10

  15. Problems

  16. Problem 1 Question Write a program that asks the user to input 2 numbers A and B, then exchange the values of A and B.

  17. Problem 1 Answer

  18. Problem 1 Answer

  19. Problem 2 Question Write a program that asks the user to type 5 integers and then prints the average of these 5 integers .

  20. Problem 2 Answer

  21. Problem 2 Answer

  22. Problem 3 Question Write a program that reads in the length and the width of a rectangular yard. Your program should compute the time required (in minutes) to cut the grass at the rate of 2.3 square meters per a second.

  23. Problem 3 Answer

  24. Problem 3 Answer

  25. Problem 4 Question Write a program that asks the user to type the price without tax of one kilogram of tomatoes, the number of kilograms you want to buy and the tax in percent units. The program must calculate the total price including taxes.

  26. Problem 4 Answer

  27. Problem 4 Answer

  28. Evaluations

  29. Question Write a program that prompts the user to input a length expressed in inches. The program should then convert the length to centimeters. Hint (One inch equals 2.54 centimeters.)

  30. Answer

  31. Problem 5 Answer

More Related