latest Post

How to add two numbers in C++ by two methods


So hey guys we are going to study some programs which basic one only so these programs dosen't come with any topics and in the next post there will be part second of previous post so this is the new series so you can see this if you want to learn it .

To add two numbers

Method 1

#include<iostream.h>
#include<conio.h>
class abc(abc is the name of class)
{
                   int a,b;
                   public:
                                void input( )
                                {
                                                    cout<<"\n enter any two number:";
                                                    cin>>i>>j;
                                }
                                void addition( )
                                {
                                                         cout<<"addition="<<i+j<<endl;  
                                }
};
void main( )
{
                    abc a;
                    a.input( );
                    a. addition( );
                    getch( );
}

Method 2

#include<iostream.h>
#include<conio.h>
void main( )
{
               int i,j;
               cout<<"enter two numbers:
               cin>>i>>j;
               int c= i+j;
               cout<<"add="<<c<<endl;
               getch();           
}

About hack guru

hack guru
Recommended Posts × +

0 comments:

Post a Comment