Practical 3.1 C++
Practical 3.1 C++
Practical 3.1 C++
of Mechatronics
Experiment: 3.1
LIST OF SUB-PROGRAMS-
Practical 8.1: WAP to perform exception handling for Divide by zero Exception.
Solution:
#include <iostream>
if( b == 0 ) {
return (a/b);
int main () {
int x = 50;
int y = 0;
double z = 0;
try {
z = division(x, y);
cout<< z <<endl;
return 0;
Output:
University Institute of Engineering Department
of Mechatronics
Practical 8.2:WAP to implement the exception handling with the functionality of testing the throw
restrictions.
Solution:
#include <iostream>
#include <conio.h>
try {
if (test==0)
if (test==1)
if (test==2)
int main( ) {
cout<< "start\n";
handle(0);
handle(1);
handle(2);
cout<< "end";
return 0;
Output:
University Institute of Engineering Department
of Mechatronics
• Apply different techniques to decompose a problem and programmed a solution with its sub modules.
• Analyze and explain the behavior of simple programs involving the programming addressed in the
course.
• Implement and evaluate the programs using the syntax and semantics of objectoriented programming.
• Design the solution of real-world problems in order to determine that the program performs as
expected.