Sum of each consequent 5 even number

Print sum for each consequent 5 even numbers starting from 1. The loop will continue up to the 100.

Example of  Output:
Sum: 30 [2,4,6,8,10 are the first 5 even number]
Sum: 90
etc.

3 comments:

  1. I need help, Please help me, sir?

    ReplyDelete
  2. /* Sum of each consequent 5 even number */
    /* Author name:Md-Naimul Hasan shohan */
    #include
    using namespace std;
    void consequent()
    {
    cout<<"The first 5 even number are:"<<endl;
    int count=0,sum=0;
    for(int i=1;i<=100;i++)
    {
    if(i%2==0)
    {
    cout<<i<<"\t";
    sum+=i;
    count++;
    if(count==5)
    {
    break;
    }
    }
    }
    cout<<endl;
    cout<<"The sum of first 5 even number is:"<<sum;
    }
    int main()
    {
    consequent();
    return 0;
    }

    ReplyDelete
  3. /* Shahenur islam, ID: 201630405
    #include

    using namespace std;

    int main()
    {
    int i,j,count=1,b=0;
    cout<<"First Ten Prime Numbers Are\n"<<"2";

    for(i=3;i>0;++i)
    {
    for(j=2;j<=i/2;++j)
    {
    if(i%j==0){
    b=1;
    break;
    }
    }

    if(b==0)
    {
    cout<<"\n"<<i;
    count++;
    }

    b=0;
    if(count==10)
    break;
    }

    return 0;
    }

    ReplyDelete