
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

6K+ Views
In this article, we will explore the purpose of using function prototypes in C or C++. What are Function Prototypes? The function prototypes tell the compiler about the number of arguments and the required data types of function parameters; they also tell the compiler about the return type of the function. With this information, the compiler cross-checks the function signatures before calling it. If the function prototypes are not mentioned, then the program may be compiled with some warnings and sometimes generate some strange output. Purpose of a Function Prototype When a function is called before it is defined, and ... Read More

28K+ Views
In C or C++, we cannot return multiple values from a function directly. In this Article, we will see how to use some trick to return more than one value from a function. Returning Multiple Values from a Function We can return multiple values from a function by using the method. Below is the list of methods that are used to return multiple values from a function in C/C++: Using Pointers Using Structures Using Arrays Returning Multiple Values Using Pointers Pass the arguments by their addresses ... Read More

296 Views
Let us see how to generate random numbers using C++. Here we are generating a random number in range 0 to some value. (In this program the max value is 100).To perform this operation we are using the srand() function. This is in the C library. The function void srand(unsigned int seed) seeds the random number generator used by the function rand.The declaration of srand() is like below:void srand(unsigned int seed)It takes a parameter called seed. This is an integer value to be used as seed by the pseudo-random number generator algorithm. This function returns nothing.To get the number we ... Read More

20K+ Views
The Pi is a special mathematical value, approximately 3.14159, that is often used in calculations related to circles and geometry. In C++, we need to understand how to access and use this constant in our programs. In this article, we will show how to use the PI constant in a C++ program. The PI constant is available in the cmath header file. We will explain how to use PI to calculate values like the area or circumference of a circle. How to Use Pi in C++ There are multiple ways to use the Pi constant in C++. ... Read More

217 Views
In this article we will see how to use the namespace in C++ code.Consider a situation, when we have two persons with the same name, Zara, in the same class. Whenever we need to differentiate them definitely we would have to use some additional information along with their name, like either the area, if they live in different area or their mother’s or father’s name, etc.Same situation can arise in your C++ applications. For example, you might be writing some code that has a function called xyz() and there is another library available which is also having same function xyz(). ... Read More

336 Views
In this article, we will learn how to pass command line parameters in C++. The command line argument is a parameter that is passed to a program when it is invoked by the command line or terminal. Parsing Command Line Parameters in C++ In C++, we can pass the command line argument using the argc and argv[] parameters that are passed to the main function. Where argc refers to the number of arguments passed, and argv[] is a pointer array that points to each argument passed to the program. We can use loops to iterate and parse the command line ... Read More

7K+ Views
Here we will see how to print leading zeros as output in C++. We know that if we directly put some zeros before some numeric values, then all zeros are discarded, and only exact numbers are printed.Printing Leading Zeros with C++ Output Operator We can manipulate the output sequence in C++ by utilizing the iomanip header. In this header, we have two manipulators, setw() and setfill(). The setw() function is used to create space between the previous text and the current text, and then we use setfill(char) to add characters to that field. Example of Printing Leading Zeros In this ... Read More

782 Views
In C/C++, both ternary operator and if-else statements are conditional statements: A condition statement expresses the relationship between two ideas or events. Where one is dependent on the other. If the condition is true, the if statement will return; otherwise, the else statement will return. Ternary Operator We know that the ternary operator is the conditional operator. Using this operator, we can check some conditions and do some tasks according to those conditions. Without using the ternary operator, we can also use the if-else conditions to do the same. Following is The Syntax of the Ternary Operator: condition ? expression_if_true ... Read More

1K+ Views
In this article, we Implement the C program to find the sum of two numbers without using any Operator. Find Sum of Two Numbers Without Using Any Operator in C This problem is tricky. To solve this problem we are using the minimum width features of the printf() statement. We can use '*' which indicates the minimum width of output. For example, in this statement "printf("%*d", width, num);", the specified 'width' is substituted as *, and 'num' is printed within the minimum width specified. If the number of digits in 'num' is less than the provided 'width', the output will ... Read More

2K+ Views
In the C programming language, the printf() function is used to print ("character, string, float, integer, octal, and hexadecimal values") to the output screen. To demonstrate the value of an integer variable, we use the printf() function with the %d format specifier. Let's see a C statement and guess the result: printf("%d %d %d", i, ++i, i++); Here, in the above C statement, both 'i' and 'i++' are in the argument list; this statement causes undefined behaviour. The sequence in which the arguments are evaluated is not specified; orders may alter depending on the compiler. At different times, a ... Read More