3.22-3.26

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The following program segment converts an angle in degrees to radians. const double PI= 3.14159; double degrees , radians; cout << "Enter an angle in degrees and I will convert it\n"; cout << "to radians for you: "; cin >> degrees; radians= degrees* PI / 180; // Display the value in radians left-justified , in fixed-point // notation, with four decimal places of precision, in a field // seven spaces wide.

/* Add this in */ cout<<degrees<<" degrees is "<<fixed<<left<<setprecision(4)<<setw(7)<<radians<<" radians.";

If a program contains the definition string name; indicate whether each of the following lettered program statements is legal or illegal. A)cin>>name; B)cin.getline(name,20); C)cout<<name; D)name="John";

A)Legal B)Illegal C)Legal D)Legal

If a program contain the definition char name[20]; indicate whether each of the following lettered program statements is legal or illegal. A)cin>>name; B)cin.getline(name,20); C)cout<<name; D)name="John";

A)Legal B)Legal C)Legal D)Illegal

Write cout statements with stream manipulators that perform the following: A) Display the number 34.789 in a field of nine spaces with two decimal places of precision. B) Display the number 7.0 in a field of five spaces with three decimal places of precision. The decimal point and any trailing zeroes should be displayed. C) Display the number 5. 789e+12 in fixed-point notation D) Display the number 67 left-justified in a field of seven spaces.

A)cout<<setw(9)<<fixed<<setprecision(2)<<34.789; B)cout<<setw(5)<<fixed<<setprecision(3)<<7.0; C)cout<<fixed<<5.789E12; D)cout<<left<<setw(7)<<67;

Will the following string literal fit in the space allocated for name? Why or why not? char name[4]="John";

No because "" have a \o at the end that is hidden in the data, so it takes up 5bytes and not 4.


Set pelajaran terkait

Chp. 5 Genetic and congenital Disorders

View Set

sqaures between 10-20 plus 25 and 30

View Set

Chapter 32: Skin Integrity and Wound Care

View Set

Unit 2: Reactions and Stoichiometry Practice Problems

View Set

C840 Cyber Forensic (Test Question v2)

View Set

Correct Order of Blood Flow in the Heart

View Set