In C, data type of result of comparison operations is int. For example, see the following program.
#include<stdio.h> int main() { int x = 10, y = 10; printf("%d \n", sizeof(x == y)); printf("%d \n", sizeof(x < y)); return 0; } |
chevron_right
filter_none
Output:
4 4
Whereas in C++, type of results of comparison operations is bool. For example, see the following program.
#include<iostream> using namespace std; int main() { int x = 10, y = 10; cout << sizeof(x == y) << endl; cout << sizeof(x < y); return 0; } |
chevron_right
filter_none
Output:
1 1
This article is contributed by Rajat. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Write a program that produces different results in C and C++
- Comparison of static keyword in C++ and Java
- Assigning an integer to float and comparison in C/C++
- Comparison of boolean data type in C++ and Java
- Comparison of Exception Handling in C++ and Java
- Comparison of a float with a value in C
- How to check whether a number is in the range[low, high] using one comparison ?
- Ratio Manipulations in C++ | Set 2 (Comparison)
- Comparison of Java with other programming languages
- Comparison of Python with Other Programming Languages
- Floating Point Operations & Associativity in C, C++ and Java
- Operations on struct variables in C
- Merge operations using STL in C++ | merge(), includes(), set_union(), set_intersection(), set_difference(), ., inplace_merge,
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- fesetround() and fegetround() in C++ and their application
- Lex program to take input from file and remove multiple spaces, lines and tabs
- Queries to insert, delete one occurrence of a number and print the least and most frequent element
- Get first and last elements from Array and Vector in CPP
- Similarities and Differences between Ruby and C language
- Code Optimization Technique (logical AND and logical OR)

