Programming and Graphics

(Kiana) #1

3.4 Keyboard and monitor 67


cout<<"\nThe Greatest Common Divisor is: "<<k<<endl
}
}

goto again;
quit:

cout<<"\n Thank you for your business\n";
return 0;
}

The text directive “\t” in the secondcoutcommand and elsewhere emulates
theTabkey. A typical session follows:


Will compute the Greatest Common Divisor
of two positive integers

Please enter the first integer
0 quit
34 12

Please enter the second integer
0 quit

The Greatest Common Divisor is: 2

Please enter the first integer
0 quit
0

Thank you for your business

Problems


3.4.1.Write a program that receives from the keyboard a vector with three
elements consisting of characters, and prints them on the screen.


3.4.2.Write a program that receives your first and last name as a single string
from the keyboard, and prints it on the screen.


3.4.3.Write a code that receives from the keyboard an integer and assesses
whether it is even or odd based on the modulo operator.


3.4.4.Write a statement that sounds a beep by (a) printing an ASCII charac-
ter, and (b) printing a code.

Free download pdf