It is possible and easy to create a new header file. Create a file with function prototypes that need to use inside the program. Include the file in the ‘#include’ section from its name.
-
-
Int data type only capable of storing values between – 32768 to 32767. To store 32768 a modifier needs to use with the int data type. Long Int can use and also if there are no negative values unsigned int is also possible to use.
-
There are 5 modifiers available in C programming language as follows. Short Long Signed Unsigned long long
-
In the following C program, struct variable st1 contains pointer to dynamically allocated memory. When we assign st1 to st2, str pointer of st2 also start pointing to same memory location. This kind of copying is called Shallow Copy. # include <stdio.h> # include <string.h> # include <stdlib.h> struct test { char *str; }; int main() { struct test st1, st2; st1.str = (char *)malloc(sizeof(char) * 20); strcpy(st1.str, "GeeksforGeeks"); st2 = st1; st1.str[0] = 'X'; st1.str[1] = 'Y'; /* Since copy was shallow, both strings are same */ printf("st1's str = %s\n", st1.str); printf("st2's str = %s\n", st2.str); return 0; }…
-
1) Precedence of prefix ++ and * is same. Associativity of both is right to left. 2) Precedence of postfix ++ is higher than both * and prefix ++. Associativity of postfix ++ is left to right. The expression ++*p has two operators of same precedence, so compiler looks for assoiativity. Associativity of operators is right to left. Therefore the expression is treated as ++(*p). Therefore the output of first program is “arr[0] = 10, arr[1] = 20, *p = 11“. The expression *p++ is treated as *(p++) as the precedence of postfix ++ is higher than *. Therefore the output of second program is “arr[0] = 10, arr[1]…
-
Heap Area:It is used for the objects allocated dynamically (Using malloc() and calloc()). Stack Area:It is used to store local variables and arguments of a method. This stays in memory only till the termination of that particular method.
-
Let’s take an example to understand it. Suppose double a=1.5; int b=10 and we want to calculate a+b By type demotion, float type a will convert to int. Therefore a=1 and a+b=1+10=11 but we know that correct answer is 11.5 which will only get by type promotion. So the conclusion is that by type demotion we will not get the correct answer.
-
These are some old concepts used in 16 bit Intel architectures in the days of MS DOS, not much useful anymore. Near pointer is used to store 16 bit addresses means within current segment on a 16 bit machine. The limitation is that we can only access 64kb of data at a time. A far pointer is typically 32 bit that can access memory outside current segment. To use this, compiler allocates a segment register to store segment address, then another register to store offset within current segment. Like far pointer, huge pointer is also typically 32 bit and can access outside segment. In case…
-
Semi-colon is needed by the compiler and as the name suggests Preprocessors are programs that process our source code before compilation. Therefore the semi-colon is not required.
-
Modifier is a prefix to the basic data type which is used to indicate the modification for storage space allocation to a variable. Example– In 32-bit processor storage space for the int data type is 4.When we use it with modifier the storage space change as follows. Long int -> Storage space is 8 bit Short int -> Storage space is 2 bit