Group starting at 2:55 PM must finish by 3343 P3 p (5 point bonus if the followi
ID: 3599126 • Letter: G
Question
Group starting at 2:55 PM must finish by 3343 P3 p (5 point bonus if the following is done correctly!!) On the desktop, create a folder beginning with the number in the upper-left corner of this sheet followed by your first initial and five letters of your last name. The two projects are to be saved to this folder. Please note that your programs may be lost if your worl is not saved correctly 1.(40) Write a program that will prompt the user for some number of integers, read in that number of integers find the sum of the digits and print out the the number of digits that are even. Save the source file as progl.epp 2. (60) Write a program that will use the following function prototypes: int readAbsoluteData(double data[I);: lask user for number of points, read in points and store the absolute value of each entered value in data and return number of points void sort(double datal], int numpts ):/sort the values from lowest to highest double bigSum(double datal), int numpts); /return the sum of all values greater than 10 readAbsolute Data to read in the number of points along with the absolute value of the data points In sort, the data read in by readAbsoluteData is to be sorted. In bigSum, find the sum of all values greater tha 10. Each function including work on main and readAbsoluteData and get that to work before going on to the other functions. Save the source file as prog2.cpp. g main is worth 15 points. Don't try to enter all the code and then debug. Instead Be sure to add your name as a comment at the beginning of each program!! Be sure to have your name printed out in each program and sign the honor code below. I have neither given nor received aid on this graded examination Print your nameExplanation / Answer
1.
#include <iostream>
using namespace std;
int main() {
int n,p,digit,sum_of_digit=0,number_of_even_digits=0;
cout<<"Enter some number of integers = ";
cin>>n;
while(n>0)
{
digit = n%10;
sum_of_digit+=digit;
if(digit%2==0)
number_of_even_digits++;
n=n/10;
}
cout<<" Sum of the digits"<<sum_of_digit;
cout<<" number of even digits"<<number_of_even_digits;
}
2.
#include <iostream>
using namespace std;
int readAbsoluteData(double (&data)[1000])
{
int i,n;
double n1;
cout<<"enter the number of points:";
cin>>n;
for(i=0;i<n;++i)
{
cout<<" enter the point:";
cin>>n1;
if(n1<0)
n1*=-1;
data[i]=n1;
}
return n;
}
void sort(double (&data)[1000], int numpts)
{
int c,d;
double swap;
for (c = 0 ; c < ( numpts - 1 ); ++c)
{
for (d = 0 ; d < numpts - c - 1; ++d)
{
if (data[d] > data[d+1])
{
swap = data[d];
data[d] = data[d+1];
data[d+1] = swap;
}
}
}
}
double bigSum(double data[1000], int numpts)
{
int i;
double sum=0;
for(i=0;i<numpts;++i)
{
if(data[i]>10)
sum+=data[i];
}
return sum;
}
int main() {
double data[1000];
int numpts = readAbsoluteData(data);
sort(data,numpts);
double sum = bigSum(data,numpts);
cout<<" sum of points greater than 10: "<<sum;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.