please i need help in my c++ assignment

its about loop ( while and for) and i cant do it

im gonna write it and hoping if any one can solve them before 25\10

pleaaaaaaaaaaaaaaaaaaaaaaaaaaase

1- write a c++ program that will read in the integer N, and calculate:
a) the factorial : N! =N (N-1) (N-2).....(2)(1)

b)the summation : N^2 = )^2 + 1^2 + 2^2 +......N^2

2- Write a program segment that prints the factorials for the numbers o through 7.

3- Write a program that will print all prime numbers between 1 and 1000.

4- write a program that asks the user to enter 5 grades. The program must calculate and print the minimum, the average and the maximum.

5- Write a c++ program that reads x and y then calculate x^y (y is an integer).

6- Read the following problem statement then formulate the algorithm using pseudo code and flowchart.

i have still more but for now please solve these ones

## All 4 Replies

This OP deserves an applaud, he is so honest that he is directly giving us his assignment copy and asking us directly to code for him. :D

Really sorry,here your honesty doesn't pay you the code you need.You need to work.Work hard and code yourself.

well.............i m trying until now....................i solved questions one, two and three but im now stucked in question...........my code is repeating the prime numbers alot not just once ......................please can u help me

this is my code

``````#include <iostream>
using namespace std;
int i,n;

int main()
{
cout<<"Welcome to c++ program"<<endl;

for (n=1;n<=1000;n++)
{
for (i=2;i<=n-1;i++)
{
if (n%i==0)
break;
else
cout<<n<<endl;
}
}
return 0;
}
``````

can u correct it for me?

Well the thing is that, You get to know if a certain number is prime .. After you have checked it with all the numbers. But here .. You are checking it with each number and then printing them up. So its like you are determining if a number is prime only by checking it once.

A Basic flag would help you out tremendously.

So here is what you have to do.
Take a boolean value and set it to "TRUE" ...
Go through the second for loop. If a number divides the main number perfectly , then you will need to change the boolean value to "False" and break.

Outside the 2nd for loop .. you check if the boolean is set to true or false. if true, print the number..... else do nothing :)

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.