Check The Programming Section
Comparatively, an unsigned data type can hold larger values and represents only positive values. A signed data type can have both positive and negative values. Unsigned uses the leading bit as part of the value. But, a signed data type considers the leading bit, to represent a number as positive or negative. If the leading bit (most significant bit) is 1 it is considered a negative number otherwise a positive number. By default unsigned is the default modifier of the int data type and signed modifier is the default modifier for char data type.
Every program in C/C++ must contain a global function called main, which is designed as the starting point of execution. A main function can have any of these following forms:
int main() {//body}
int main(int argc, char *argv[ ]){//body}
void main(){//body}
argc - it represents a non-negative value, which has the count of number of parameters, passed from the environment in which the program is run.
argv - it is an array of pointer and points the first element of an array of argc + 1 pointers and is null to the last element and the previous ones, if any null terminated multi-byte string is passed as argument to the main method. These arguments are passed from the execution environment such as the operating system.
body - represents the body of the main method
The main function is called by the operating system after initialisation as a non-local object with static storage duration. The parameters passed to the main function are known as command line arguments. These arguments are used to pass a multi-byte string and the pointer argv[0] points the first character of the null-terminated string. The string passed to the main function is modifiable and does not propagate back to the calling environment.
A main function have several properties as follows:
A main function should be placed anywhere of the program
Normally, a main function should not called recursively
Its address should not be taken
A C/C++ program or project must have atleast and atmost one main function and it must be defined in a global space.
By default the compiler fits numeric constants to its smallest compatible data type. Consider the example below:
23 is considered as integer constant in 16-bit system and
103,000 is considered as long constant
Sometimes we wish to allocate a larger memory requirement to a smallest integer constant. In C/C++, we can use L or l as suffixes after a constant value. L or l represents a long integer, takes 4 byte memory in a 16-bit system. For example, 23L is considered a long integer constant and 4 bytes memory blocks are assigned to 23. Similarly, the suffix U or u forces a constant to be an unsigned. Consider the below statement:
cout<<ULONG_MAX<<" "<<-1U;
Here -1 is considered as an unsigned value and -1 is converted to unsigned long value to 4294967295. Further, we can also mixed up U and L together and forms various types of integer constants as follows:
If a constant has the U suffix, its data type will be the first of the following that can accommodate its value: unsigned short, unsigned int, unsigned long int.
If a constant has the L suffix, its data type will be the first of the following that can accommodate its value: long int, unsigned long int.
If a constant has both L and U suffixes, (LU or UL), its data type will be unsigned long int.
If a constant has the LL, its data type will be long long.
If a constant has the ULL, its data type will be unsigned long long.
In C/C++, the smallest type of floating-point constants assume to be double. For floating-point types, if you follow the number with an F or f, the number is treated as a float. If you follow it with an L, the number becomes a long double. Consider the sample code listed below:
cout<<sizeof(2.4)<<" "<<sizeof(2.4f)<<" "<<sizeof(2.4L);
sizeof() is an operator, which returns the allocated memory in bytes for constants. The output of the above code is 8 for double floating-point (without any suffixes), 4 for single floating-point, and 10 for long double constant type.