Introduction
C++ is one of the most widely used programming languages for competitive programming. Learning C++ reinforces essential computer science principles while also providing access to a wide range of professional options.
Comparison operations specify how the system should compare an incoming value supplied as a context parameter to a predetermined value or value range. Instead of being supplied by a context parameter, the test parameter can also be supplied as the result of a nested expression. The sizeof() function is used for comparing the results of the operations in C and C++.
So, let's start with a brief description of the sizeof() function.
Also see : C Static Function
Click on the following link to read further: Features of C Language
sizeof function
In C/C++, the Sizeof() operator is a machine-dependent feature that changes from compiler to compiler. It's possible to call it byte-specific functionality. It aids in the allocation of variables to memory by supplying the byte and size of the variables, as well as the number they occupy. The Sizeof() method is only used to determine the precise size of a variable type in C/C++ programming. The sizeof operator has a return type that returns the total number of bytes in memory. It is particularly beneficial in the implementation and development of portable apps because of its adaptability and flexibility.
Lets understand the working of the sizeof() function with the help of an example.
Consider the code snippet:
#include <stdio.h>
int main(){
int x=sizeof(50); //Assign the value of size of Integer to x
int y= sizeof(50.5); //Assign the value of size of Double to y
printf("The size of Integer is %d \n The size of double is %d", x,y);
return 0;
}
Output:
The size of Integer is 4
The size of double is 8
Explanation:
In the code snippet, x is assigned with the value of Integer, and y is assigned the value of Double. Hence based on the compiler, the output is 4 and 8, respectively.
Let's get into the details of the results of comparison operations in C and C++.
You can also read about the jump statement, Tribonacci Series and Short int in C Programming
Must Read Passing Arrays to Function in C