DSPS: add consecutive numbers(upto n)

//============================================================================
// Name        : incremental_addition.cpp
// Author      : Parashar
// Version     :
// Copyright   : Do not try this at home ;P
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
#define n 10

class add
{
public:
    int a,i;
public:
    void incadd();
};

void add::incadd()
{
    int total=0;
    for(i=1;i<=n;i++)
    {
        total=total+i;
    }
    cout<<total;
}

int main()
{
    cout << "!!!Made by PARASHAR!!!" << endl;
    add a;
    a.incadd();
    return 0;
}

Comments

Popular posts from this blog

NASM: program to find largest number from an array of 32-bit numbers(hard-coded)

Rules for drawing a FLOWCHART