This is a multiple-branching statement where, based on a condition, the control is transferred to one of the many possible points. This is implemented as follows: switch (expression) &...
Hello there We all know that we can use Structure in C programming and also can store structure data in HDD by using fwrite() function. However, I am making a simple mini project with C programming. With this project us...
Turbo C++ and Borland C++ provide an integrated program development environment under MS DOS. They provide a built-in editor and a menu bar which includes options such as File, Edit, Compile and Run. We can create and...
A function can not only receive objects as arguments but also can return them. The example in program… #include <iostream>using namespace std;class complex // x + iy form{ flo...
Namespace is a new concept introduced by the ANSI C++ standards committee. This defines a scope for the identifiers that are used in a program. For using the identifiers defined in the namespace scope we must include the...
ChainedAssignment x = (y = 10); or x = y = 10; First10 is assigned to y and then to x. A chained statement can not be used to initialize variables at the ...
Anexpression is a combination of operators, constants and variables arranged as per the rules of the language. It may also include function calls which return values. An expression may consist of one or more operands and...
We can use pointers not only to the base objects but also to the objects of derived classes. Pointers to objects of a base class are type-compatible with pointers to objects of a derived class. Therefore, a single point...
Polymorphism in another important OOP concept. Polymorphism, a Greek term, means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the ...
Detection of the end-of-file condition is necessary for preventing any further attempt to read data from the file. An ifstream object, such as fin, returns a value of 0 if any error occurs in the file operation inc...
Wecan use the width() function todefine the width of a field necessary for the output of an item. Since, it is a member function; we have to use an object to invoke it, as shown below: cout.width(w); Wher...
Wecan read and display a line of text more efficiently using and line-oriented input function getline(). The getline() function reads a whole lineof text that ends with a newline character (transmitted by the RETURN key...
OOP offers several benefits to both the program designer and the user. Object-orientation contributes to the solution of many problems associated with the development and quality of software products. The new technology ...
The function open() can be used to open multiple files that use the same stream object. For example, we may want to process a set of files sequentially. In such cases, we may create single stream object and use it to ope...
Templates is one of thefeatures added to C++ recently. It is a new concept which enable us to define genetic classes and functions and thus provides support for generic programming. Generic programmingis an approach whe...
The function put() writes a single character to the associated stream. Similarly, the function get() reads a single character from the associated stream. The program requests for a string. On receiving the string, the pr...
A data member of a class can be qualified as static. The properties of a static member variable are similar to that of a C static variable. A static member variable has certain special characteristics. These are: • ...
By default, the floating numbers are printed with six digits after the decimal point. However, we can specify the number of digits to be displayed after the decimal point while printing the floating point numbers. This c...
Hybrid inheritance is a combination of multiple inheritance and multilevel inheritance. A class is derived from two classes as in multiple inheritance(Multiple Inheritance is a feature of C++ where a class can inherit fr...
The constructors can also be used to allocate memory while creating objects. This will enable the system to allocate the right amount of memory for each object when the objects are not of the same size, thus resulting in...
Wecan mix data types in expressions. For example, M = 5+2.75; is a valid statement. Wherever data types are mixed in an expression, C++ performs the conversions automatically. This process is known as im...
Both C and C++ compilers support all thebuilt-in(also known asbasicor fundamental) data types. Withthe exception of void, the basicdata types may have several modifierspreceding them to serve the needs of various situati...
It is possible to take address of amember of a class and assign it to a pointer. The address of a member can be obtained by applying the operator & to a “fully qualified” class member name. A class member pointer...
Classes can be defined and used inside afunction or a block. Such classes are called local classes. Examples: void test (int a) // function { …………. ………...
This C++ Program converts decimal to binary value. The program takes a number as the input and prints out the binary form of the number using a recursive function which is given the number as the parameter. #inclu...
C uses malloc() and calloc()functions to allocate memory dynamical at run time. Similarly, it uses the function free() to free dynamicallyallocated memory. We use dynamic allocation techniques when it is not known in a...
A Stack is a linear data structure which is used to store data in a particular order. Two operations that can be performed on a Stack are: Push operation which inserts an element into the stack. Pop operation which remov...
Overloading refers to the use of the same thing for different purposes. C++ also permits overloading of functions. This means that we can use the same function name to create functions that perform a variety of different...
A class can inherit the attributes of two or more classes. This is known as multiple inheritance. Multiple Inheritance allows us to combine the features of several existing classes as a starting point for defining new cl...
Today I have just learned about Inheritance in C++ programming. I thought I should share what I learnt today !! I hope it will be helpful for anyone... Inheritance in Object Oriented Programming can be described as a pr...
Hello there I have just started learning C++. At my college we use Turbo C++ but I don't like that compiler because I think its outdated. For this reason I use and like Codeblocks. Because its more advanced then Turbo. ...
Hello there Today I have started learning file management functions at C and C++. I have wrote a program to take input some integers from user and save them into a txt file. In the program I have used append mode to tak...
I have just wrote the linear search program today. here is the code . . . #include <iostream>using namespace std;int main (){int data[] = {10,20,36,98,55,200,258,986,458,88};int i,k...
C & C++ are computer programming languages that are used to write programs to communicate with computer. Lets see what is the difference between these two programming languages. C programming language...C is a mi...
Today I have just write a simple program to find factorial of a number. I have done this for college. I have wrote and run the code with CodeBlocks But when I was trying to run the code with trubo it was giving wrong res...
Hello there I am learning C and C++. I am using Turbo and CodeBlocks as my regular compiler. Though I use CodeBlocks most. Turbo is outdated its don't have much features, but Codeblocks have a lot features. That is why ...
Hello there I am doing a simple C programming project. For the project I will need to use two dimensional array and also will need to store all the array data/elements in my HDD. I mean after exiting the program interre...
Hello guys I am a student of Computer Technology. I am studying C/C++ and very soon will start Java. Its really hard to study three language at a time. But there is no way to avoid this ! Because I have to study C/C++ a...