Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To write a program that uses several different kinds of functions. For this assi

ID: 3710463 • Letter: T

Question

To write a program that uses several different kinds of functions.

For this assignment, we're going to try something new. Instead of telling you exactly how your program should work, I'm giving you an open-ended assignment. You dedide what you want your program to do. It just has to follow these rules:

Your program must have at least 3 functions in addition to main.

All variables must be declared inside functions (no global variables).

At least 2 of the functions must have parameters which are needed and used correctly.

At least 1 funtion must return a value.

At least 1 function must not return a value (declared using "void").

Each function should have a comment next to its prototype and body, briefly explaining what it does, and who wrote it.

Your will get full credit for this assignment if you follow all of these rules, and your program works correctly, doing whatever it says it will do.

Explanation / Answer

// Since the programming language is not given, I am doing it in C++, let me know if you need solution in any other programming language

// C++ code , all the points mentioned in question are taken care of

#include <iomanip>

#include<iostream>

#include <string.h>

#include <stdlib.h>

using namespace std;

//Your program must have at least 3 functions in addition to main.

// three function are below

//All variables must be declared inside functions (no global variables).

// At least 1 funtion must return a value.

//Each function should have a comment next to its prototype and body, briefly explaining what it does, and who wrote it.

int getInteger() // function to get an input from user

{

int n;

cin >> n;

return n;

}

// At least 2 of the functions must have parameters which are needed and used correctly.

int getSum(int n1, int n2) // function to get sum of two integers

{

return (n1+n2);

}

// At least 1 function must not return a value (declared using "void").

void displayResult(int sum) // function to display rsult

{

cout << "Sum of two integers is " << sum << endl;

}

int main()

{

int integer1, integer2;

cout << "Enter integer1: ";

integer1 = getInteger();

cout << "Enter integer2: ";

integer2 = getInteger();

int sum = getSum(integer1, integer2);

displayResult(sum);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote