// constructor program to add two number's
// program written by SuNiL kUmAr
#include<iostream.h>
#include<conio.h>
class constructor
{
private:
int a,b;
public:
constructor(int m,int n);
int sum();
};
constructor::constructor(int m,int n)
{
a=m;
b=n;
}
int constructor::sum()
{
int s;
s=a+b;
return (s);
}
int main()
{
int x,y;
clrscr();
cout<<"enter two number's to add \n";
cin>>x>>y;
class constructor k (x,y);
cout<<"sum of two number's is = "<<k.sum();
getch();
return (0);
}
Chat with our AI personalities
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
mano ni anda yarrr
b + b + b + c + c + c + c = 3b + 4c
c + c + c + c + c = 5 * c.
Not defined by the language, it depends on the OS/platform/context. Usually, it is the terminal(emulation) or DOS-shell or console in which the program runs.