Saturday, 5 October 2013

C++ pointers practice if that no is that then do that!! with the help of point

#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

void main()
{
    int a,b;
    int *ptr;
    int result;
    cout<<"point checking program\n";
    cout<<"if first number is greater then second then ADD \n";
    cout<<"if second number is greater then first then ADD \n";

    cout<<"enter the two numbers:";
        cin>>a>>b;
        if(a>b)
        {
            result = a+b;
            ptr=&result;
        }
        else if(a<b)
        {
            result = a-b;
        ptr = &result;
        }
        else
        {
            cout<<"wrong answer";
        }
        cout<<"value of the result is "<<result;
        cin>>result;
}