C++ Programming
- Write a C++ Program to print a welcome text in a separate line.
- Write a Program in C++ to add two numbers.
- C++ program for addition of two numbers using functions.
- Add two numbers in C++ using class.
- Addition of two numbers using call by reference in C++
- C++ program to write a program to add two numbers using call by value.
- Swapping of two numbers in C++ without using third variable.
- Swap two numbers in C++ using function.
- C++ program to swap two numbers using class.
- C++ program to swap two numbers using call by value.
- C++ program to swap two numbers using pointers.
- Write a program to swap private data members of two classes using friend function.
- write a program to add data objects of two different classes using friend function.
- Threading in C++.
- C++ thread lambda
- C++ thread lambda with parameter
- C++ thread lambda pass by reference
- Singleton C++ example
What are the differences between int, long, long long, and short? Between an unsigned and a signed type? Between a float and a double?
Short uses less memory and than int, long and long long. Minimum size of short and int is 16 bits, long has 32 bits, and long long has 64 bits. In C language the main difference is their size and range. Short is of 2 bytes and it’s value is from -32,768 to 32,767, int is of 4 bytes and its value is from -2,147,483,648 to 2,147,483,647, Long is of 4 bytes and it’s value is from -2,147,483,648 to 2,147,483,647 and long long is of 8 bytes and it’s value is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
A signed variable can hold both positive and negative values. An unsigned variable can only hold positive integers. Both signed and unsigned can be applied to short, int, char and long. We can use cast to convert from signed to unsigned type and from unsigned to signed type.
Float and double both are used to represent floating point numbers or decimal digits. Size of the float is 32 bits and for double it is 64 bits. Float has 7 decimal digits precision whereas double has 15 digits precision.