1 / 10

Tutorial 1

Tutorial 1. Chapter 1 and 2. Exercise 1. Show the output displayed by the following program lines when the data entered are 5 and 7. Exercise 2. Cout<<“Enter two integers“; Cin<<m<<n; m = m + 5; n = 3 * n; Cout<<“m =“<<m<<end1; Cout <<“n=“<<n;. Exercise 3.

marlie
Download Presentation

Tutorial 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. Tutorial 1 Chapter 1 and 2

  2. Exercise 1

  3. Show the output displayed by the following program lines when the data entered are 5 and 7. Exercise 2 Cout<<“Enter two integers“; Cin<<m<<n; m = m + 5; n = 3 * n; Cout<<“m =“<<m<<end1; Cout <<“n=“<<n;

  4. Exercise 3 Show the output displayed by the following lines if the value of exp is 11. Cout<<“My name is “; Cout<<“Hoda Ahmed.”; Cout<<endl; Cout<<“I live in “; Cout<<“Riyadh, Olaya Street “<<endl; Cout<<“and I have “ << exp<< “ years “; Cout<<“of programming experience.”;

  5. Write a program that draws a simple triangle of stars on screen. Exercise 4 Write 2 separate programs that show the following:1.)Hello, World!2.)Hello, World! Exercise 5

  6. Exercise 6: Draw a flowchart then write a program that calculates the total salary, Given that a user will enter the salary and overtime. Note: Total-Sal = Salary +Overtime ******************** Salary 2500 Overtime 1250 Total-Sal= 3750 ********************

  7. Exercise 7: Draw a flowchart and write a program to calculate the product of two numbers. Your output must be: Please enter first number: 5.5 Please enter second number: 2.5 The Product is 13.75

  8. Exercise 8: Where possible, write equivalents for the following statements using compound assignment operators: • r = r / 10; • z = z * x + 1; • q = q + r * m;

  9. Exercise 9: Find the value of x, when j = 5 and k = 2: • x = j +1*k-3; • x = k-j*2(j+1); • x = j++ - ++k; • x = j++; • X=++k;

  10. Assume the following: int j = 6; int k = 10; int n; bool b = false; Give the value that is assigned, or illegal. • __________ n = k++; • __________ n = (k++); • __________ n = ++k; • __________ n = 7++; • __________ n = k++ + ++j; • __________ n = k+++++j; • __________ n = k = j = 5; • __________ n = k = (j = 5); • __________ n = (k = j) = 5; • __________ 3 = 4; • __________ n = k; n += 1; • __________ n = k; n *= 2; • __________ n = k; n /= 2;

More Related