Write a driver C++ program that will test the following functions in the same or
ID: 673661 • Letter: W
Question
Write a driver C++ program that will test the following functions in the same order they are written next. You can test your program by reading the following values: n1= 10 and n2= 20 from the user:
The main program does not send the values of the variables n1 and n2 to the function. This means that the function will ask the user to enter the values. The function calculates the average and sends it back to main program through the parameter list as call by reference parameter as it will not use the return statement.
Explanation / Answer
#include<iostream.h>
void main()
{
void av(int *a1, int *a2);
int n1,n2;
cout<<"Enter 2 numbers";
cin>>n1>>n2;
av(&n1, &n2);
}
void av(int *a1, int *a2)
{
int a=(*a1+*a2)/2;
cout<<"Average is "<<a;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.