Posts

Showing posts with the label oop

C++ Program to Add Complex Numbers by Passing Structure to a Function

Add Complex Numbers by Passing Structure to a Function This program takes two complex numbers as structures and adds them with the use of functions. Example: Source Code to Add Two Complex Numbers // Complex numbers are entered by the user #include <iostream> using namespace std ; typedef struct complex { float real ; float imag ; } complexNumber ; complexNumber addComplexNumbers ( complex , complex ); int main () { complexNumber n1 , n2 , temporaryNumber ; char signOfImag ; cout << "For 1st complex number," << endl ; cout << "Enter real and imaginary parts respectively:" << endl ; cin >> n1 . real >> n1 . imag ; cout << endl << "For 2nd complex number," << endl ; cout << "Enter real and imaginary parts respectively:" << endl ; cin >> n2 . real >> n2 . imag ; ...

Structures in C++

Structures A  data structure  is a group of data elements grouped together under one name. These data elements, known as  members , can have different types and different lengths. For example:  You want to store some information about a person: his/her name, citizenship number and salary. You can easily create different variables  name, citNo, salary  to store these information separately. However, in the future, you would want to store information about multiple persons. Now, you'd need to create different variables for each information per person:  name1, citNo1, salary1, name2, citNo2, salary2 You can easily visualize how big and messy the code would look. Also, since no relation between the variables (information) would exist, it's going to be a daunting task. A better approach will be to have a collection of all related information under a single name  Person , and use it for every person. Now, the code looks much cleaner, readable...

Hello world

Image
  https://www.youtube.com/watch?v=f98EqpP4mlc   C++codes   
Image
Hello Dear Friends!      We Are Present For You Its My First Post, And In Other l'll Post Many More After This.With the Help of This You Can Learn And Clear Your C++ Concepts.