Question:

Help me!!!! C++ problem?

by  |  earlier

0 LIKES UnLike

Please help me!!! I have no idea how to solve all these C++ questions. I tried many ways to solve them. unfortunately there still some error when i run the program.

Here are the questions:

1. Use while loop to show that the following series converges to 2:

1-1/3+1/5-1/7+...

i tried it but the program keep running to infinity and i have to press

ctrl+alt+del to stop it....please help me.

2. Write a program to print out the following pattern by using for loop

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7

1 2 3 4 5 6

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

I dont know how to do this.

3. Write a program to calculate the mean and variance of ten positive

integers input by the user. The mean, m and variance, v are defined

as follows:

m =∑(xi/n); ===> mean formula

v =∑(xi-m)2/n; ===> variance formula

can use any type of loop structure either while loop, do-while loop or

for loop.

Please...help me to solve it. i need to submit them next week, on August 29.

 Tags:

   Report

1 ANSWERS


  1. for your second question, use a nested while-for loop like this

    int i=9;

    while(i<=1)

    {

    for(int j=1;j<=i;j++)

    {

    cout << j << " ";

    }

    cout << endl;

    i--;

    }

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions