IoE (Institute of Engineering)

The Institute of Engineering, established in 1930, is the first technical school of Nepal. It was reformed in the present shape in 1972 as an organ of Tribhuvan University. Besides producing low and tertiary level technicians, IOE runs professional diplomas, undergraduate, postgraduate and Ph.D. programs.

Electrical Club Members of NCE

IOE ELECTRICAL CLUB is the team of electrical students studying at IOE. The group was established to fascilate the students to share their ideas regarding electrical technology and electrical projects. The club helps students to support and guide the projects in which they are engaged in

Various Sports Awards

The Nepal national basketball team represents Nepal in international basketball competitions and is managed by the NCE College.

Wireless Electric Vehicle Charging Technology

Wireless electricity is quite literally the transmission of electrical energy without wires.The principle behind the Tesla coil is to achieve a phenomenon called resonance.The massive amount of energy makes the magnetic field collapse quickly, and generates an electric current in the secondary coil.

Winner

“No man needs sympathy because he has to work, because he has a burden to carry. Far and away the best prize that life offers is the chance to work hard at work worth doing.”

Showing posts with label oop. Show all posts
Showing posts with label oop. Show all posts

C++ IOE Note By Anup sir(IOE Pulchowk all subject note )

C++ IOE Note By Anup sir(IOE Pulchowk blog)


http://notepulchowkcampus.blogspot.com/
C++ note

 Click Below to Download Full Note by Anup Shretha sir in PDF or Read below in blog (IOE Best teacher at C++)
http://notepulchowkcampus.blogspot.com/
Click Me




Exception Handling:

It is required to develop a fault tolerance software system.  If a software program is provided with exceptional handling mechanism then the software will smoothly run in spite of presence of fault.

Exception handling mechanism generally uses three keywords they are:

try , catch and throw statement.

è The part of code that generate the exception should be placed in try block.

è if any exception occurs then it is thrown using throw keyword

è the exception handling code or mechanism is placed in catch block.

  • Example 1 of exception handling in c++ :
  • Example of exception handling in oop :

#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

int a,b,x;

cout<<"Work: a/(a-b)\nEnter the value of a and b"<<endl;

cin>>a>>b;

x=a-b;

try

{

if (x!=0)

{

cout<<"\nThe division is "<<a/x<<endl;

}

else

{

throw(x);

}

}

catch(int y)

{

cout<<"\nException is found"<<"Division can not occur by zero difference"<<y<<""<<y;

}

 

return 0;

}

 

 

 

https://notepulchowkcampus.blogspot.com/
exception handling in c++ :

 

 

 

  • Example 2 of exception handling in c++
  • Example 2 of exception handling in oop

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

                float x;

                int a;

                cout<<"\nEnter number"<<endl;

                cin>>a;

                try

                {

                                if( a>0)

                                {

                                                x=sqrt(a);

                                                cout<<"\nSquare root  of "<<a<<"is "<<x<<endl;

                                }

                                else

                                {

                                                throw(a);

                                }

                }

                catch(int x)

                {

                                cout<<"Square root of negative number "<<a<<" is not possible"<<endl;

                }

                return 0;

}

Re throwing exception:

if we can not handle the exception completely i.e. caught by catch block then we rethrow that exception by using throw keyword only without using any argument. This is called re throwing exception.

this cause the current expression to be pass into the out of try catch block;

  • Example of re throwing exception.in c++:

#include<iostream>

using namespace std;

int main()

{

                int a,b,x,c;

                cout<<"Enter the value of a and b"<<endl;

                cin>>a>>b;

                x=a-b;

                try{

                                if(x!=0)

                                {

                                                cout<<"The resul is "<<(a/x)<<endl;

                                }

                                else

                                {

                                                throw(x);

                                }

                }

                catch(int x)

                {

                                cout<<"\nException Found\n";

                                throw;

                }

                return 0;

}

Catching all exception:

in c++ there is provision of catching all exception raised in try block of code without considering their data type. This provision is known as catching all exception.

in other word catching all exception will catch all the exception of any data type raised from try block.

  • syntax for catching all exception:

catch(…)

{

                //handling all type of exception

}

  • Example of catching all exception in c++:

#include<iostream>

using namespace std;

void function(int test)

{

                try

                {

                                if (test==0)

                                {

                                                throw(test);

                                }

                                else if (test==1)

                                {

                                                throw(1);

                                }

                                else if (test==2)

                                {

                                                throw(2);

                                }

                                else

                                {

                                                cout<<"\nCalled function other than 0, 1,2";

                                }

                }

                                catch(...)

                                {

                                                cout<<"All Exception Caught";

                                }

               

}

int main()

{

                cout<<"\nCalling function with 0";

                function(0);

                cout<<"\nCalling function with 1";

                function(1);

                cout<<"\nCalling function with 2";

                function(2);

                cout<<"\nCalling function with 3";

                function(3);

                return 0;

}

 

 

Multiple handling

In C++ there is provison of handling multiple exception that is generated from  try block 

but in the case of multiple handler we use separate catch block to handle exception of each data type.

  • Example of multiple handling in c++

catch (int a)

{

cout<<"integer found"<<endl;

}

catch (char ch)

{

cout<<"character  found"<<endl;

}

catch (float c)

{

cout<<"float  found"<<endl;

}

 #allnoteofexceptionhandlinginc++,#exceptionhandlinginc++,#exception handling in c++

https://notepulchowkcampus.blogspot.com/


Share:

subscribe

IOE ALL SUB NOTES

Delivered by FeedBurner

Wikipedia

Search results

The quality of being the only one of its kind.

If you are fresher or preparing to attempt the Back Exam then you are going to be happy to know that here you will find all the shortlisted targeted question for your subject. Here you will find perfect answers to your questions