Wednesday, January 13, 2021

New and delelte operator in c++

 


#include <iostream>
using namespace std;
int main()
{
    int *p1, *p2, sum;
    p1 = new int;
    p2 = new int;
    cout << "Enter first value: " << endl;
    cin >> *p1;
    cout << "Enter secend value: " << endl;
    cin >> *p2;
    sum = *p1 + *p2;
    cout << "Sum of first and second value is :" << sum << endl;
    delete p1;
    delete p2;

    return 0;
}

No comments:

Post a Comment