
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
Server Side Programming Articles - Page 2285 of 2651

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

635 Views
We pass different arguments into some functions. Now one questions may come in our mind, that what the order of evaluation of the function parameters. Is it left to right, or right to left?To check the evaluation order we will use a simple program. Here some parameters are passing. From the output we can find how they are evaluated.Example Code#include void test_function(int x, int y, int z) { printf("The value of x: %d", x); printf("The value of y: %d", y); printf("The value of z: %d", z); } main() { int a = 10; test_function(a++, a++, ... Read More

2K+ Views
In this section we will see how to count number of arguments in case of variable number of arguments in C.The C supports ellipsis. This is used to take variable number of arguments to a function. User can count the arguments by using one of the three different ways.By passing the first argument as count of the parametersBy passing last argument as NULL.Using the logic like printf() or scanf() where the first argument has the placeholders for other arguments.In the following program, we will total number of variable of arguments passed.Example Code#include #include int get_avg(int count, ...) { ... Read More

3K+ Views
Here we will see how to write a code where two functions are present, and one function will be executed before the main function, and another function will be executed after the main function. These features are used to do some startup task before executing the main, and some cleanup task after executing main.To do this task we have to put attribute for these two functions. When the attribute is constructor attribute, then it will be executed before main(), and when the attribute is destructor type, then it will be executed after main().Example Code#include void before_main() __attribute__((constructor)); void after_main() __attribute__((destructor)); ... Read More

5K+ Views
Here we will see why we should use function prototype in C. The function prototypes are used to tell the compiler about the number of arguments and about the required datatypes of a function parameter, it also tells about the return type of the function. By 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.If some function is called somewhere, but its body is not defined yet, that is defined after the current line, then it ... Read More

302 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

218 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

347 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