



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab journal for computer programming. It covers topics such as input output statements, data types, arithmetic operators, and the const keyword. code examples and exercises for the reader to practice. The lab journal also includes a bonus problem for the reader to attempt. suitable for students studying computer programming.
Typology: Exercises
1 / 6
This page cannot be seen from the preview
Don't miss anything!




char grade = ‘A’; cout << "Grade is :" << grade << endl; Output: int marks = 80; cout << "Marks are :" << marks << endl; Output: int marks; cout << "Enter marks: "; cin >> marks; cout << "Marks are:" << marks << endl; Output: float radius; float pi = 3.14; float circum; cout << "Enter radius: "; cin >> radius; circum = 2 * pi * radius; cout << "Circumference of circle with radius " << radius << " is "<< circum << endl;
Output: This code has two errors. Solve them First before writing the output. Hint: You can build the program and see the ErrorList Window to see the errors. Or you can also see the red squigly line in your compiler underlining the point of error. double radius = 250800000; //in inches const float pi = 3.14; double circumOfEarth; circum = 2 * pi * radius; cout << "Circumference of Earth in inches with radius " << radius << " is "<< circum << endl; Output: const float pi = 3.14; cout << "Enter value of pi: "; cin >> pi; cout << "Value of pi is "<< pi << endl; Build this program. You will see that it has an error on the input line of the program. Now remove the keyword const before the variable pi and build now. Does it still has an error? NO So you see the values of const variables (who has the word const before them) can not be changed/modified in the program. They are constant! What did you learn about const keyword? The word constant only declares const not variables //This is a program that increase the value of count variable by 1. int count = 10; count = count + 1;
Code: Output:
Code: Output:
Code: