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

part 1 Write a program that asks the user for a positive integer value. The prog

ID: 3712703 • Letter: P

Question

part 1 Write a program that asks the user for a positive integer value. The program should then print out all of that value's factors. That is, it should print out all positive integers, besides 1 and the value itself, that evenly divide that value part 2 Write a program that computes the average of the numbers entered by the user. The program should first ask the user how many values they want to enter. The program should then read in that many values and print out the average of those values. You do not need to store the individual values

Explanation / Answer

#include<iostream>

using namespace std;

int main() {

int n;

cout<<"Enter a positive number: "<<endl;

cin >> n;

cout<<"Factors: "<<endl;

for(int i=1;i<=n;i++) {

if(n % i == 0) {

cout<<i<<" ";

}

}

cout<<endl;

}

Output:

#include<iostream>

using namespace std;

int main() {

double sum = 0;

int n, value;

cout<<"Enter the number of elements: "<<endl;

cin >> n;

for(int i=0; i<n; i++){

cout<<"Please enter a number: "<<endl;

cin >> value;

sum+=value;

}

double average = sum/(double)n;

cout<<"The average is : "<<average<<endl;

}