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;
}


c++ Counting Table in which u set limit where to count

#include <iostream>

using namespace std;
int main () {
    int x,a,m;
    cout<<"number for the table to count"<<endl; cin>>a;
    cout<<"pleas enter the limit for upto table to print"<<endl;
    cin>>m;
    for(int i =1;i<=m;i++)
    {
        cout<<a<<" X "<<i<<" = "<<a*i<<endl;
    }
    cout<<endl<<"XXXXXXXXXXXXXXXXXX"<<endl;
}