create a c++ program that has 3 functions with return type void first function is called Sum the second function is called Information and the third is called Calculation.
a) in the definition of Sum function, you should creat 5 random numbers and print their sum value.
b) in the information function, you should let the user enter his name (Gretta) his major (graphic design) his height (176) his age(23), then you should print all the entered information concatenated with a "-"
c) in the third function Calculation, you should let the user enter any two numbers, and you should print the multiplication of the entered numbers.
d) call the three function from main.
e) using for loop, display the value of the function information 5 times.

So what seams to be your problem. Just posting your homework will get you nowhere. I will offer to do it for \$1000 USD that that is a limited time special offer.

Well, my fee is \$1100 USD but it don't have a time limit.

## All 5 Replies

So what seams to be your problem. Just posting your homework will get you nowhere. I will offer to do it for \$1000 USD that that is a limited time special offer.

Well, my fee is \$1100 USD but it don't have a time limit.

although you did not specify the range for your random numbers i assumed 1-100 should be just fine.

``````#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

void sumFunction() // sumFunction will generate five random numbers [1-100] , then display the sum of all
{
int rand1, rand2, rand3, rand4, rand5, totalSum; // initiate variables , int data type
rand1 = rand() % 100 + 1;
rand2 = rand() % 100 + 1;
rand3 = rand() % 100 + 1;
rand4 = rand() % 100 + 1;
rand5 = rand() % 100 + 1;
totalSum = rand1 + rand2 + rand3 + rand4 + rand5;
cout << "Total sum for the random numbers generated was : " << totalSum << endl;
}

void informationFunction() // information function will ask the user to enter his/her info and display the information concatenated with a "-"
{
cout << "Please enter the following Informations : " << endl;
cout << "name : " << endl;
cout << "Major : " << endl;
cin >> userMajor;
cin.ignore(100, '\n');
cout << "age : " << endl;
cin >> userAge;
cout << "height : " << endl;
cin >> userHeight;
cout << "User full information : " << userName + "-" + userMajor + "-" + userAge + "-" + userHeight << endl;
}
void calculationFunction() // ask user to entere any two numbers and display the multiplication results
{
float firstNum, secondNum, totalMult;
cout << "Please enter first number : " << endl;
cin >> firstNum;
cout << "Please enter second number : " << endl;
cin >> secondNum;
totalMult = firstNum * secondNum;
cout << "Multiplication of the two numbers you entered = " << totalMult << endl;
}
int main() // main method
{
sumFunction();
informationFunction();
calculationFunction();

system("pause");
return 0;
}
``````

@ Rafiii - Do not do homework for others that show no effort.

in this problrm statement you need the following
how to write a function.
how to use the for loop
how to create object in the main function.
I have posted a function. it can input and output a name
first middle last,
Go through the codes and spend some time solving it.
You will exactly know How to write a function.
All you have to do is change the data type.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.