VOOZH about

URL: https://www.geeksforgeeks.org/c/output-c-programs-set-63-2/

⇱ Output of C programs | Set 63 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Output of C programs | Set 63

Last Updated : 20 Dec, 2017
1) What is the output of the following program? Output:
8 1 6 5 5
Explanation : p is a pointer so sizeof returns sizeof(char*), *p is of type char, sizeof("geeks") returns the number of characters including the null character, strlen(p) returns length of string pointed by p without null character and strlen returns number of characters without null character. 2) What is the output of the following program? Output:
2 1 3
Explanation : The above initialization technique is unique but allowed in C. 3) What is the output of the following program? Output:
1
Explanation : Even if this is function pointer, the sizeof will get the return type and returns the size of that data type. Here, the return type is char, so the output is 1. 4) What is the output of the following program? Output:
4
Explanation: The '!' operator takes an argument and return 1 if the value is 0 and 0 otherwise. So, !2.3 is 0. To sizeof 0 is an integer and so the output is 4. 5) What is the output of the following program?
Output:
Compilation error
Explanation: The macro declare will be replaced before the compilation and the result code will have “int a” declaration twice in the program which will cause compilation error.
Comment
Article Tags:
Article Tags: