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 BEL2075OOPRegular. Show all posts
Showing posts with label BEL2075OOPRegular. Show all posts

OOP C++ IOE NOTE NCE NOTE

C++ IOE Computer Electrical OOP Note for final exam for 32 Mark conform


C++ IOE Computer Electrical OOP Note for final exam for 32 Mark conform

Inline function: 

It is the function that is expanded inline when it is called with corresponding code. The syntax for making inline is inline return-type function-name(no arguments/arguments) 

Note:- inline function should always have return type.

Advantage: 
  • It reduces the exception time of a program with function having fewer lines of codes.
Disadvantage: 

  • The execution time of inline function is more than normal function if the function has the larger number of codes or more lines of code. 
  • It does not work for the recursive course. 

Default Arguments:

 C++ allows programmers to call a function without specifying all its arguments. In such case function assigned a default value to the parameters which does not have matching arguments in function call. These value in function definition are called default arguments. 

Note: while assigning a default value , we should place the default from right to left. 

eg:- 

  • float simple (int P, int t, float r=0.15) (default argumernt or legal) 
  • float simple(int p, int t=2,float r) (illegal) 
  • float simple(int p, int t=2,float r=0.15) (legal) 

Inline and default arguments: 

C++ IOE Computer Electrical OOP Note for final exam for 32 Mark conform

function overloading:

function overloading means using same function name to perform variety of task. But in function overloading we must consider two things. They are:

  • 1.       Either the number of arguments in function should be different (the number of input to function should vary).
  • 2.       if the number of arguments are same then the data type of the function arguments should be different number of parameter  different.

Note: return type has no role in function overloading

int sum(int a, int b)

{

return (a+b);

}

int sum(int a1, int b1, int c1)

{

return(a1+b1+c1);

}

int sum(int d)

{

return (d+5);

}

void main()

{

cout<<"The sum of one variable"<<sum(10)<<endl;

cout<<"The sum of two variable"<<sum(10,20)<<endl;

cout<<"The sum of three vriable"<<sum(10,20,30)<<endl;

getch();

}

Q. write a program to calculate the area of rectangle and triangle using concept of function overloading.

type II

#include<iostream.h>

#include<conio.h>

using namespace std;

int area(int l, int b)

{

return (l*b)

}

float area(int b, float h)

{

return (0.5*b*h);

}

void main()

{

int l1,b1;

float  h;

cout<<"Enter the value of l1,b1 & h1<<endl;

cin>>l1>>b1>>h1;

cout<<"The area of rectangle is <<area(l1,b1)<<endl;

cout<<"The area of triangle is<<area(l1,h1);

getch();

}

 Reference variable:

Ans:  Is an alternative name given to the original variable. any changes made to reference variable will change original variable and vice versa.

the syntax for making reference variable is:-

data-type & reference_variable = original variable

eg:- int &a(reference variable)=X(original variable)

#include<iostream.h>

#include<conio.h>

using namespace std;

void main()

{

int x=5;

int &a=x; // making refrance variable

a=a+5;

cout<<"The value of x is"<<x<<endl;

getch();

}

output =10

                            

Q. is the concept of alternative variable used for pass by reference ? if yes show with an appropriate example.

Ans: pass by reference: provision of reference variable in c++ allows us to pass parameter to the function by reference. when we pass argument by reference the formal argument in the function call (the input variable of function definition) becomes alternative variable ( or reference variable) of the variable in function call.

#include<iostream.h>

#include<conio.h>

using namespace std;

void swap (int &a, &b)

{

int temp=a;

a=b;

b=temp;

}

void main()

{

int x1=5,y1=6;

cout<<"before swapping x1="<<x1<<endl<<"y1="<<y1<<endl;

swap(x1,y1);    // function call

cout<<"After swapping"<<"x1="<<x1<<endl<<"y1"<<y1<<endl;

getch();

} 

Q. wap to calculate area and perimeter of rectangle in a function and display the result in main().

#include<iostream.h>

#include<conio.h>

using namespace std;

void rectangle(int l, int b, int &A1, int &P1)

{

A1=l*b;

P1=2*(l+b);

}

void main()

{

int l1,b1,A,P;

cout<<"Enter the value of l1 and b1"<<endl;

cin>>l1>>b1;

rectangle (l1,b1,A,P);

cout<<"Area of rectangle is "<<A<<endl<<"Perimeter of rectangle is"<<P<<endl;

getch();

}

 

Return by reference: 

In return by reference in true case c++ assign a reference value . in return by the function is called as:

syntax: function call = reference value;

eg:-

Max(a,b)=200; (reference value  )

the syntax for function definition in return by reference is

return-type & function_name(data_type1 & variable1,data type2 and variable 2...... upto n)

example of return by reference:

 #include<iostream.h>

#include<conio.h>

using namespace std;

int &Max(int &a, int &b)

{

if (a>b);

{

return (a);

}

else

            {

            return (b);

            }

}

void main()

{

int a=10, b=5;

Max(a,b)=200;  // function call

cout<<"a="<<a<<endl<<"b="<<b<<endl;

getch();

}

output: a=10, b=5

Q. How memory is allocated dynamically for normal variable and array?

Ans: Memory is allocated dynamically for normal variable by using syntax:-

pointer-variable = new data type

eg:-

int *p;

p=new int;

alternatively we can combine to allocate dynamically

syntax: data-type *pointer variable = new data type

 

for array

syntax

data type *pointer = new data type (size)

eg:-

int *p = new int [20];

 

class and object:

class:

  • 1.       a class is a way to bind data and associated function together.
  • 2.       it allows data and function to hidden if necessary for external use.
  • 3.       defining a class means creating a user defined data type that behaves as built in data.
  • 4.       once a class has been declared we can create any number of object belonging to that class.

syntax:

class class_name

{

private:

data member;

member function;

public:

data member;

member function;

};          //end of class

 

Generally data are placed in private section and function are placed in public section.

  • 5.       class contains both data and function . Data are called data member and function are called member function.
  • 6.       data and function are defined in private section are not accessible out of the class.
  • 7.       data and function placed in public section are only accessible from outside the class.
  • 8.       the word private is optional . the data in function of class by default private.

object:

  • ð  object are the basic entities of oop. the object may be person place or anything's that have some physical attribute. Object are the variable of class in terms of programming.

syntax:

class_name objects_name(variable name)

Share:

2075 Chaitra OOP pulchowk campus engineering note

2075 Chaitra Regular engineering note
https://notepulchowkcampus.blogspot.com/

2075 Chaitra Regular Object-Oriented Programming IOE Pulchowk engineering note

1. What are the main features of Object-Oriented Programming? Would you consider it better than structured programming? If you do, what makes it better? Write down its advantages and disadvantages.

2. What do you mean by constructor and destructor? Explain the necessity of copy constructor with example. Also, explain the order of the invocation of constructor and destructor with example.

3. What type of language is C++? Explain its features.

4. What is function overloading? How is pass by reference done in C++? Explain with a suitable example.

5. Write the syntax of operator overloading. Create a class called time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to zero (0), and another should initialize it to fixed values. A member function should display it in 10:45:30 format. The final member function should add two objects of type time passed as arguments using operator overloading.

6 How the function overriding differ from function overloading? When do we face ambiguity problems in multiple inheritances? Explain.

7. What is pure virtual function? Discuss the role of virtual functions in C++ to cause dynamic polymorphism. Show with an example of how it is different from the compile-time polymorphism.

8. What are different file access pointers? Write a program to store and retrieve the information of the Client(Client ID, Account ID, name, address, and age) in the Bank management system. Also, calculate the total number of clients in a bank.

9. Explain the function template? How do you use the function template with multiple template types? Give an example

10. What is an exception and what is the mechanism of exception handling in C++? Write a program to illustrate the process of handling multiple exceptions.
https://notepulchowkcampus.blogspot.com/
full-width
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