SOURCE CODE:
#include <iostream>
using namespace std;
void function1();
float TriangleArea(float height,float base);
float SumNumbers(float n1,float n2,float *sum);
float Arraysum(int arr[]);
const string name="Student";
const string Assignment="Assignment-1";
int main()
{
float height=0,base=0,area=0;
float n1=0,n2=0,sum=0;
float average=0;
function1(); //calling function 1 to display
name and assignment
cout <<endl<<"Enter height of the
Triangle:" ;
//reading Triangle height from user
cin >> height;
//reading Triangle base from user
cout <<"Enter base of the Triangle:"
;
cin >> base;
//calling TriangleArea function
area=TriangleArea(height,base);
//printing area value
cout << "Area of Triangle is :" <<
area << endl;
cout <<endl<<"Enter first number:"
;
//reading 1st number
cin >> n1;
//reading 2nd number
cout <<"Enter second number:" ;
cin >> n2;
//calling SumNumbers function
SumNumbers(n1,n2,&sum);
cout << "Sum is :" << sum
<<endl;
int a[12]={1,2,3,4,5,6,7,8,9,10,11,12};
average=Arraysum(a);
cout << endl<< "Average of array
values is:" << average;
return 0;
}
void function1()
{
// printing name Assignment name
cout << "Name: " << name <<
endl << "Assignment: " << Assignment <<endl
;
}
float TriangleArea(float height,float base)
{
float area=0;
//TriangleArea calculation
area=(0.5)*height*base;
return area;
}
float SumNumbers(float n1,float n2,float *sum)
{
*sum=n1+n2;
}
//function to read array of 12 values calculating sum and return
average
float Arraysum(int a[])
{
int i=0,sum=0;
float average=0;
for(i=0;i<12;i++)
{
//calculating sum
sum=sum+a[i];
}
cout << "Sum of 12 values :" <<
sum;
//calculating average
average=sum/12.0;
return average;
}
CODE
SCREENSHOT:
OUTPUT:
MUST BE WRITTEN IN C++ All user input values will be entered by the user from...
In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...
code in C++ Create a program that uses the pass by reference operator instead of the return command. Your main program will need to: create empty variables call void function 1 with no input to display your name to the screen call function 2 to collect the square feet that a gallon of paint covers from user call function 2 to collect the square feet of wall that needs to be painted call function 3 to calculate the number of...
C++ Program Int Main First Please Write one program that does the following: 1. 1. Ask the user for ten (10) grades, and store the data in an array. Compute the average of all the grades. Print the original ten grades and the average. a. Declare an integer array with the name of “grades” of size 10 in the main function. b. Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array. i. The function will receive...
Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...
Write a complete C++ program that is made of functions main() and rShift(). The rShift() function must be a function without return with 6 parameters. rShift() should do following. Shift the first 4 formal parameters' value one place to right circularly and send the updated values out to the caller function, i.e. main. Furthermore, after calling this function with first 4 actual parameters, say a1, a2, a3, a4, and these actual parameters should shift their value one place to right...
python Write a progran that reads values from the user until a blank line is entered. Display the total of al1 the values entered by the user (or 0.0 if the first value entered is a blank 1ine). Complete this task using recursion. program must not use any loops. Your Hint: The body of your recursive function will need to read one value from the user, and then determine whether or not to make a recursive call. Your funetion does...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
Hi I need help doing this problem *The program must re-prompt as long as invalid input is inserted Implement a program that manages shapes. Implement a class named Shape with a virtual function area()which returns the double value. Implement three derived classes named Diamond, Oval, and Pentagon. Declare necessary properties in each including getter and setter function and a constructor that sets the values of these properties. Override the area() function in each by calculating the area using the defined...
You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...