Found 1339 Articles for C

Need of long data type in C

Anvi Jain
Updated on 30-Jul-2019 22:30:25

400 Views

In C or C++, there are four different datatypes, that are used for integer type data. These four datatypes are short, int, long and long long. Each of these datatypes takes different memory spaces. The size varies in different architecture and different operating systems. Sometimes int takes 4-bytes or sometimes it takes 2-bytes. This also happen for the compilers. So we can use cross compilers.The cross compilers are basically a compiler, which is capable of compiling for a platform other than current platform.So if we want to compile the following code in 32bit system, and 64-bit system, it will generate ... Read More

Benefits of C over other languages

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

The C programming language was developed by Dennis Ritchie during early 1970. It was developed to redesign UNIX operating system.Earlier the B language, which was used for UNIX system, it has different drawbacks. It does not support structures, and did not understand datatypes. For this reason, the C language was introduced. C has high level functionality, and detailed feature for OS programming. The UNIX kernel was developed by using C.Advantages of C languageC is medium level language. It has both, the lower level and higher level functionality. We can use C to make driver or kernel level programs as well ... Read More

C/C++ Struct vs Class

Smita Kapse
Updated on 30-Jul-2019 22:30:25

419 Views

In C++ the structure and class are basically same. But there are some minor differences. These differences are like below.The class members are private by default, but members of structures are public. Let us see these two codes to see the differences.Example#include using namespace std; class my_class {    int x = 10; }; int main() {    my_class my_ob;    cout

What does the operation c=a+++b mean in C/C++?

Aman Kumar
Updated on 30-Jul-2025 15:03:20

2K+ Views

In C/C++, the expression c = a++ + b indicates that the current value of a is added to b, and the result is assigned to c. After this assignment, a is incremented by 1 (post-increment), which means the increment of a happens after its value is used in the expression. Well, let a and b initialize with 2 and 5, respectively. This expression can be taken as two different types. c = (a++) + b c = a + (++b) The above two expressions contain both post and pre-increment ... Read More

_Noreturn function specifier in C

Ravi Ranjan
Updated on 11-Jul-2025 18:16:55

231 Views

The _Noreturn function specifier in C indicates to the compiler that the function will either exit or run in an infinite loop. This function never returns the control to the main function or wherever it was called in the program. If the _Noreturn function uses the return statement, the compiler will generate a warning or show an undefined behavior. Syntax of _Noreturn Function Specifier The syntax of _Noreturn function specifier is given below: _Noreturn data_type function_name() { --- code lines --- } _Noreturn with exit() Function in ... Read More

What happens when a function is called before its declaration in C?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

334 Views

If we do not use some function prototypes, and the function body is declared in some section which is present after the calling statement of that function. In such a case, the compiler thinks that the default return type is an integer. But if the function returns some other type of value, it returns an error. If the return type is also an integer, then it will work fine, sometimes this may generate some warnings.Example Code#include main() {    printf("The returned value: %d", function); } char function() {    return 'T'; //return T as character }Output[Error] conflicting types for 'function' ... Read More

What is the purpose of a function prototype in C/C++?

Aman Kumar
Updated on 12-Jun-2025 14:58:45

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

How can we return multiple values from a function in C/C++?

Aman Kumar
Updated on 18-Jun-2025 18:38:24

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

What is evaluation order of function parameters in C?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

621 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

How to Count Variable Numbers of Arguments in C?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

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

Advertisements