0% found this document useful (0 votes)
61 views

Tutorial For Biginers C++

This document contains a tutorial on basic C++ concepts including: 1. Suitable data types for student information like index number (string), age (int), GPA (float), and grade (char) 2. Naming rules for variables in C++ 3. Converting mathematical formulas to C++ arithmetic expressions 4. Sample programs to demonstrate input/output and arithmetic operations 5. A program to read and output numbers with division and remainder calculations 6. Identifying and correcting a Celsius to Fahrenheit conversion formula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Tutorial For Biginers C++

This document contains a tutorial on basic C++ concepts including: 1. Suitable data types for student information like index number (string), age (int), GPA (float), and grade (char) 2. Naming rules for variables in C++ 3. Converting mathematical formulas to C++ arithmetic expressions 4. Sample programs to demonstrate input/output and arithmetic operations 5. A program to read and output numbers with division and remainder calculations 6. Identifying and correcting a Celsius to Fahrenheit conversion formula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Tutorial No: 02

1. Define suitable data type for following statements


I.
To hold student index number (Ex: AS2014234)
II.
To hold student age (Ex: 21)
III.
To hold student G.P.A (Ex: 3.67)
IV.
To hold course grade (Ex: A)
2. Briefly describe naming rules when declaring variables.
3. Convert each of the following mathematical formulas to C++ arithmetic expressions.
4.

What will be the output of the following program segments?


I.

5.

int a, b, s;
a = 5;
b = 4;
s = a + b;
cout << The sum of;
cout << a << and <<b;
cout << is << s << \n;

II.

Ffloat x, y, p;
Xx = 5.31;
Yy = 7.87;
Pp = x * y;
cout << The product of \n << x << and;
cout << y << is\n << p;

Write a complete C++ program that reads two whole numbers into two variables of type int,
and then outputs both the whole number part and the remainder when the first number is
divided by the second.

6. Given the following fragment the purports to convert from degrees Celsius to degrees
Fahrenheit, answer the following questions:
double c = 20;
double f;
f = (9/5) * c + 32.0;
I.
What value is assigned to f?
II.
Explain what is actually happening, and what the programmer likely wanted.
III.
Rewrite the code as the programmer intended.
Department of Statistics and Computer Science
University of Sri Jayewardenepura

Commented [g1]: Havent done strings. Remove this. Add an


example for long.

You might also like