Site icon DataFlair

C++ Program for Basic Programs

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// Swaping using third variables
#include<iostream>
#define clrscr() system("cls")
using namespace std;

int main()
{
    int a,b,c;
    clrscr();
    cout<<"\nEnter two number";
    cin>>a>>b;
    cout<<"\nBefore swaping "<<a <<" "<<b;
     c=a;
     a=b;
     b=c;
     cout<<"\nAfter swaping "<<a <<" "<<b;
    return 0;
}

Program 2

// Swaping using third variables
#include<iostream>
#define clrscr() system("cls")
using namespace std;

int main()
{
    int a,b,c;
    clrscr();
    cout<<"\nEnter two number";
    cin>>a>>b;
    cout<<"\nBefore swaping "<<a <<" "<<b;
     c=a;
     a=b;
     b=c;
     cout<<"\nAfter swaping "<<a <<" "<<b;
    return 0;
}

Program 3

// Arithmatic operation between to numbers
#include<iostream>
#define clrscr() system("cls")
using namespace std;

int main()
{
    int a,b;
    clrscr();
    cout<<"\nEnter two number";
    cin>>a>>b;
    cout<<"\nAddition is :"<<a+b;
    cout<<"\nSubtraction is :"<<a-b;
    cout<<"\nMultiplication :"<<a*b;
    cout<<"\nDivision is :"<<a/b;
    return 0;
}

 

Exit mobile version