×
Don’t stop when you’re tired. STOP when you are DONE.
--Your friends at LectureNotes
Close

Object Oriented Programming Using Cpp

by Shekharesh BarikShekharesh Barik
Type: NoteCourse: B.Tech Specialization: Computer Science EngineeringOffline Downloads: 81Views: 4139Uploaded: 9 months ago

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Shekharesh Barik
Shekharesh Barik
Difference between C and C++ C C++ 1. It is a procedure oriented programming. 1. It is an object oriented programming. 2. It does not support classes and object. 2. It supports class and object. 3. In c function can’t be declared inside the structure. 3. In C++ function can be declared inside the structure. 4. It does not support inline function. 4. It supports inline function. 5. It does not support function overloading. 5. It supports function overloading 6. In C scanf function is used for inputting the data. 6. In C++ Cin object is used for accepting the data. 7. The printf function is used for output of the data. 7. In C++ Cout object is used for output 8. C does not support operator overloading and inheritance. 9. It does not support reference variable. 8. C++ supports operator overloading and inheritance. 9. It support reference variable. Data Type Built in voidtype fl Integral Void Derived Floating point  int  float  char  double User defined Array Structure Function Enum Pointer Class Reference Union
Operators in C++ 1. Arithmetic operator :– (+, -, *, /, %) 2. Relational operator : –(> ,< ,>= ,<= ,==) 3. Logical operator :– (&&,||, ! ) 4. Assignment operator :– (= ,+= ,-= ,*= ,/= ,%= ) 5. Increment /decrement operator :– (++ ,-- ) 6. Bitwise operator :– (& ,! ,>> ,<<) 7. Conditional operator :– (? :) 8. Special operator :–(comma (,) size of () ) 9. Unary operator :–(++,-- ,-) 10. Binary operator :–( +,- ,/ ,* ,> ,<= ,== ) Wap to print a message #include<iostream.h> void main () { cout<<”hellow world”; } Cout << insertion operator Object of ostream class Cin >> extraction operator Object of istream class
WAP to find the sum of 2 nos #include<iostream.h> void main () { int a,b,c; cout<<”enter two nos ”; cin>>a; cin>>b; or cin >> a>>b; c=a+b; cout<<” result =”<< c ; } WAP to accept the length and breadth of a rectangle and find the area and perimeter. #include<iostream.h> void main () { int l, b, a, p; cout<<”enter the length and breadth ”; cin>>l; cin>>b; a= l *b; p=2(l+b); cout<<” area =”<< a<<” \n”; cout<<” perimeter= “<< p; } WAP to accept a temp in Fahrenheit and convert it into centigrade. #include<iostream.h> void main () { float f,c; cout<<”enter the temp in fahrenheit”; cin>>f; c= (5*(f-32))/9; cout<<” centigrade =”<< c; }
WAP to accept the 3 sides of a triangle & find the area #include<iostream.h> #include<math.h> void main () { float a,b,c,s,a; cout<<”enter the 3 sides of the triangle”; cin>>a>>b>>c; s=(a+b+c)/2; a=sqrt(s*(s-a)*(s-b)*(s-c)); cout<<” area =”<< a; } WAP to accept the 2 nos and swap with each other #include<iostream.h> void main () { int a,b,c; cout<<”enter the 2 no.s”; cin>>a>>b; c=a; a=b; b=c; cout<<” after swapping =”<<a<<b; } Wap to accept the employee-id, basic salary and name of an employee and calculate the da,hra & gross according to the following rules DA=50% of BASIC HRA= 20% of BASIC GROSS=BASIC+DA+HRA

Lecture Notes