/Chapter – 6 Getting Starting With C++

## Chapter – 6 Getting Starting With C++

Que.17. Write a C++ program to display the following output using a single cout statement:
Program = 20
Documentation = 23
Logic = 21
Flow Chart = 18

```#include < iostream.h>
void main()
{
cout << "Program = 20 n Documentation = 23 n Logic = 21 n```
``` Flow Chart = 18";
getch();```

Que.18. Write a C++ program to read values of w, x, y, and z and display the value of P, where
P = (w + x) / (y – z)

```#include
int main()
{
int w, x, y, z, P;
cout << "Enter values for w,x,y and z in order:n";  cin >> w >> x >> y >> z;
P = (w+x)/(y-z)
cout << "Value of P = " << P;
return 0;
}```

Que.19. Write a C++ program that reads the temperature in Celsius and displays it in Fahrenheit.

```// Program to read temperature in Celsius and display it in Fahrenheit.
#include
void main()
{
float c,f;
cout << "Enter temperature in Celsius:n"; cin >> c;
// Formula for Fahrenheit = (9/5)*C + 32 = 1.8*c + 32
f = 1.8*c + 32;
cout << "n Temperature in Fahrenheit is " << f;
}```

Que.20. Write a C++ program to display on the screen.
a) the character ‘z’ b) the name ‘Mohan’ c) the number 1977
(i) Using single cout statement (ii) Using multiple cout statements

(i) Using single cout statement

``` #include
int main()
{
cout << "z Mohan 1977";
}```

(ii) Using multiple cout statements

```#include
int main()
{
cout << "z";
cout << "Mohan";
cout << "1977" ;
}```

Que.21. Assuming there are 7.481 gallons in a cubic foot, write a c++ program that asks the user to enter the number of gallons and then display the equivalent cubic feet.

```// Program to convert gallons into cubic feet
#include
void main()
{
float g,c;
cout << "Enter number of gallons:n";  cin >> g;
// 1 cubic feet = 7.481 gallons
// so 1 gallon = 1/7.481 cubic feet = 0.134 cubic feet
c = g*0.134;
cout << g << " has " << c << " cubic feet";
}```

Que.22. Write a c++ program to generate the following table:

1992 17421
1993 29210
1994 100523
1995 106902
1996 127000

Use a single cout statement for output. (Hint: Make use of n and t.)

```#include
void main()
{
cout << "1992 t 17421 n 1993 t 29210 n 1994 t 100523 n 1995 t 106902 n 1996 t 127000";
}```

Que.23.Write a c++ program that generates the following output:

5
10
9

Assign value 5 to a variable using = Multiply it with 2 to generate 10 and subtract 1 to generate 9

```#include
int main()
{
int x = 5; // Used a variable to initialize 5 to it
int y = x*2; // Used another variable to multiply the previous one by 2
int z = y-1; // Used a third variable to subtract 1 from it
cout << x << "n" << y << "n" << z; // Display the output
return 0;
}```

Que.24.Write a C++ program that accepts a radius of a circle and prints its area.

```#include
void main()
{
}```

Que.25.Write a c++ program to print the output mentioned in question 23 in different lines i.e., all values must appear in the different lines.

```#include
int main()
{
cout << "5" << endl;
cout << "10" << endl;
cout << "9" << endl;
return 0;
}```

Que.26.Write a C++ program that accepts marks in 5 subjects and outputs the average marks.

```#include
void main()
{
int m1,m2,m3,m4,m5;
int average;
cout << "Enter the marks of 5 subjects in order:";  cin >> m1 >> m2 >> m3 >> m4 >> m5;
average = (m1+m2+m3+m4+m5)/5;
cout << "n Average Marks = " << average;
}```

Que.27.Write a C++ program to accept two integers and print their sum.

```#include
void main()
{
int x,y;
cout << "Enter two integers:";  cin >> x >> y;
cout << "Sum of integers = " << x+y;
}```

So, Take your time and go through these questions of C++ Book By Sumita Arora.

###### Chapter 6 Getting Starting C

Learn C++Class Notes Of C++ And Html.