100 likes | 347 Views
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.
E N D
Tutorial 1 Chapter 1 and 2
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 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.”;
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
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 ********************
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
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;
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;
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;