0% found this document useful (0 votes)
47 views1 page

#Include #Include Using Namespace Int Int

This document contains 3 programming questions and solutions. The first question asks about the correct variable types for storing different data types like numbers of books, cost of a book, number of people, and the word "Hello". The second question provides a C++ program to calculate the sum, difference, product, quotient, and remainder of two numbers input by the user. The third question provides a C++ program to get 6 integers from the user, calculate their sum, average, and product, and display the results.

Uploaded by

nidamah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

#Include #Include Using Namespace Int Int

This document contains 3 programming questions and solutions. The first question asks about the correct variable types for storing different data types like numbers of books, cost of a book, number of people, and the word "Hello". The second question provides a C++ program to calculate the sum, difference, product, quotient, and remainder of two numbers input by the user. The third question provides a C++ program to get 6 integers from the user, calculate their sum, average, and product, and display the results.

Uploaded by

nidamah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Homework 1:

1. What is the correct variable type for storing the following data:
a. The number of books in a bookshelf
int
b. The cost of this book
float
c. The number of people in the world
double
d. The word Hello
char
2. Write a program that calculates and prints sum, difference and product of two numbers. Also,
use this program to calculate remainder and quotient in division of these numbers. Display
the output on the screen.
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int n1,n2;
cout << "Enter First number : "; cin >> n1;
cout << "Enter Second number: "; cin >> n2;
cout << n1<< "+" <<n2<< "=" << n1+n2 << endl;
cout << n1<< "-" <<n2<< "=" << n1-n2 << endl;
cout << n1<< "*" <<n2<< "=" << n1*n2 << endl;
cout << n1<< "/" <<n2<< "=" << n1/n2 << endl;
cout << n1<< "%" <<n2<< "=" << n1%n2 << endl;
system("PAUSE");
return 0;
}

3. Write a program that gets 6 integers from the user and displays the sum, average and product
of these numbers on screen.
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
float n1,n2,n3,n4,n5,n6,sum,prod,avg;
cout << "Enter Six Numbers : ";
cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
prod = n1*n2*n3*n4*n5*n6;
sum = n1+n2+n3+n4+n5+n6;
avg = sum/6;
cout <<"Product = " << prod <<endl;
cout <<"Sum
= " << sum <<endl;
cout <<"Average = " << avg <<endl;
system("PAUSE");
return 0;
}

You might also like