Monday, 15 June 2015

How to add two numbers in c++ using class

This is for you my friends to learn about C/C++ amd much more

#include<iostream.h>
#include<conio.h>

class Add
       {
public:
int a,b;

void sum()
      {
cout<<a+b;
      }
void show()
       {
cout<<"Enter the value For adding\n";
cin>>a>>b;
getch();
       }
};
void main()
     {
clrscr();
Add obj;
obj.show();
obj.sum();
getch();
     }

Coding Format

Output Format

Thank You 
I hope you like it

Thursday, 4 June 2015

How to find square of a number using math.h header file in c++

#include<conio.h>
#include<iostream.h>
#include<math.h>

void main()
{
 clrscr();
 int sq,sum;
 cout<<"Enter the value for Squaring\n";
 cin>>sq;

 sum=pow(sq,2);

 cout<<"Square of the number is "<<sum;

 getch();

}
Coding Format

Output Format