Program for Function invoking Template

Home Forums C++ Program for Function invoking Template

This topic contains 0 replies, has 1 voice, and was last updated by  admin 1 month, 3 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5241

    admin
    Keymaster

    // Program for Function invoking Template
    #include <iostream>
    using namespace std;
    void divide(int x, int y, int z)
    {
    cout<<“\n We are inside the function\n”;
    if((x-y)!=0)
    {
    int R = z/(x-y);
    cout<<“Result = “< }
    else
    {
    throw(x-y); // throw point
    }
    }
    int main()
    {
    try
    {
    cout<<“We are inside the try block\n”;
    divide(10,20,30);
    divide(10,10,20);
    }
    catch(int i)
    {
    cout<<“Caught the Exception\n”;
    }
    return 0;
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.