Question

using C++ 1) write a program to calculate to avg of N number of subjects. 2)write...

using C++

1) write a program to calculate to avg of N number of subjects.

2)write a program to find the factorial of 5!

5*4*3*2*1

3)write a program to display the multiplication table for any number

please enter number : 3

1*3=3

2*3=6

2*4=

10*3=30

4) find the factorial on n

Homework Answers

Answer #1

1.program to calculate to avg of N number of subjects.


#include <iostream>

using namespace std;

int main()
{
int N;
double k,sum=0;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>k;
sum=sum+k; /* to add the score of total subjects*/

}
double Avg=sum/N;/* average of subjects*/
cout<<Avg;

return 0;
}

2.program to find the factorial of 5!

#include <iostream>

using namespace std;

int main()
{
int sum=1;
for(int i=1;i<=5;i++)
{
sum=sum*i;
}
cout<<sum;
}

3. program to display the multiplication table for any number


#include <iostream>

using namespace std;

int main()
{
int n;
cin>>n; /*taking input of a number*/
for(int i=1;i<=10;i++)
{
cout<<i<<" *"<<n<<" = "<<i*n<<"\n"; /* table of the number taken in input*/
}
return 0;
}

4. program to print factorial of n

#include <iostream>

using namespace std;

int main()
{
int n,sum=1;
cin>>n;
for(int i=1;i<=n;i++)
{
sum=sum*i;// multiplying all the numbers from 1 to n and storing it in sum
}
cout<<sum;
return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program on C++ to calculate and print the factorial of a number using a...
Write a program on C++ to calculate and print the factorial of a number using a for loop. The factorial of a number is the product of all integers up to and including that number, so the factorial of 4 is 4*3*2*1= 24.
Question: Write a C++ program to ask the user to give you the number of rows...
Question: Write a C++ program to ask the user to give you the number of rows and number of columns, then make the multiplication table by using nested loop. For example, if the user enters 3 for rows and 4 for columns then the multiplication table would be like the following: 1    2   3     4 1   1 2 3 4 2   2    4      6    8 3    3 6 9 12
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write()...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write() and read() functions with binary                                                        data, where the data is not char type.              (Typecasting is required) Fill in the blanks, then enter the code and run the program. Note:   The data is int type, so typecasting is            required in the write() and read() functions. #include <iostream> #include <fstream> using namespace std; int main() {    const int SIZE = 10;   ...
1- Write algorithm (in pseudo-code) for the following problem: sum of the series: 1 +2+3+…+N 2-...
1- Write algorithm (in pseudo-code) for the following problem: sum of the series: 1 +2+3+…+N 2- Convert an algorithm to a flowchart diagram. 3- Counting the primitive operations of the algorithm. 4- Determine algorithm complexity. 5- Write a complete C++ program for the previous algorithm where the program should contain the following:  Display messages.  Input any number;  Display the series.  Display the sum of the series.
C++ Write a program that calculates and prints the total grade for n assignments as a...
C++ Write a program that calculates and prints the total grade for n assignments as a percentage. Prompt the user to enter the value of n, followed by the number of points received and number of points possible for each assignment . Calculate and print the total number of points received, total number of points possible, and the overall percentage: (total points received / total points possible) * 100. Output: Enter·number·of·assignments·to·input:3↵ Enter·number·of·points·received·for·assignment·1 :10↵ Enter·number·of·possible·points·for·assignment·1 :10↵ Enter·number·of·points·received·for·assignment·2 :7↵ Enter·number·of·possible·points·for·assignment·2 :12↵ Enter·number·of·points·received·for·assignment·3...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
(OUTOCAD PROGRAM) Write a report on the following subjects: 1. Layer. 2. Design Center. 3. Table....
(OUTOCAD PROGRAM) Write a report on the following subjects: 1. Layer. 2. Design Center. 3. Table. 4. Block. 5. Array
Create a C++ Program that prompts the user to enter a number and compute for the...
Create a C++ Program that prompts the user to enter a number and compute for the factorial value. SAMPLE OUTPUT: ENTER A NUMBER: -5 zero & positive numbers only!!! ENTER A NUMBER: 5 Factorial of 5 : 5*4*3*2*1 = 120 DO NOT USE FUNCTION FOR THIS PROBLEM. THANK YOU   
Write a C++ program to run a menu-driven program with the following choices: Compute the factorial...
Write a C++ program to run a menu-driven program with the following choices: Compute the factorial of a number Compute the alternating factorial of a number Quit #include <iostream> using namespace std; void getValidUserInputPosNumGT0 (int *a) { int num; cout << "Enter in a positive number greater than 0... "; cin >> *a; } long double factorial (int num) { int fact = 1; while (num > 1) { fact *= num; num--; } return fact; } long double AlternatingFactorial...