My Courses
C Programming Questions and Answers – Formatted Input
C Programming Questions and Answers – Formatted Input 1.What is the output of this C code? #include <stdio.h> int main() { int n; scanf(“%d”, n); printf(“%d\n”, n); return 0; } a) Compilation error b) Undefined behavior c) Whatever user types d) Depends on the standard 2.What is the output of this C code? #include…
C Programming Questions and Answers – Variable Length Argument
C Programming Questions and Answers – Variable Length Argument 1.What is the output of this C code? #include <stdio.h> #include <stdarg.h> void func(int, …); int main() { func(2, 3, 5, 7, 11, 13); return 0; } void func(int n, …) { int number, i = 0; va_list start; va_start(start, n); while (i != 3)…
C Programming Questions and Answers – Formatted Output
C Programming Questions and Answers – Formatted Output 1.What is the output of this C code? #include <stdio.h> int main() { int i = 10, j = 2; printf(“%d\n”, printf(“%d %d “, i, j)); } a) Compile time error b) 10 2 4 c) 10 2 2 d) 10 2 5 2.What is the output…
C Programming Questions and Answers – Standard Input & Output
C Programming Questions and Answers – Standard Input & Output 1.Which among the following is odd one out? a) printf b) fprintf c) putchar d) scanf 2.For a typical program, the input is taken using a) scanf b) Files c) Command-line d) All of the mentioned 3.What does the following command line signify? prog1|prog2…
C Programming Questions and Answers – Bit-fields
C Programming Questions and Answers – Bit-fields 1.What is the correct syntax to initialize bit-fields in an structure? a) struct temp { unsigned int a : 1; }s; b) struct temp { unsigned int a = 1; }s; c) struct temp { unsigned float a : 1; }s; d) Both a and c. 2.Which of…
C Programming Questions and Answers – Unions
C Programming Questions and Answers – Unions 1.Size of a union is determined by size of the. a) First member in the union b) Last member in the union c) Biggest member in the union d) Sum of the sizes of all members 2.Comment on the following union declaration? #include <stdio.h> union temp { int…
C Programming Questions and Answers – Typedefs
C Programming Questions and Answers – Typedefs 1.What is the output of this C code? #include <stdio.h> typedef struct student { char *a; }stu; void main() { struct stu s; s.a = “hi”; printf(“%s”, s.a); } a) Compile time error b) Varies c) hi d) h 2.What is the output of this C code? #include…
C Programming Questions and Answers – Table Lookup
C Programming Questions and Answers – Table Lookup 1.What is the output of this C code? #include <stdio.h> struct student { char a[5]; }; void main() { struct student s[] = {“hi”, “hey”}; printf(“%c”, s[0].a[1]); } a) h b) i c) e d) y 2.What is the output of this C code? #include <stdio.h> void…
C Programming Questions and Answers – Self-Referential Structures
C Programming Questions and Answers – Self-Referential Structures 1.What is the output of this C code? #include <stdio.h> struct student { char *c; struct student *point; }; void main() { struct student s; struct student m; s.c = m.c = “hi”; m.point = &s; (m.point)->c = “hey”; printf(“%s\t%s\t”, s.c, m.c); } a) hey hi…
C Programming Questions and Answers – Pointer to Structures
C Programming Questions and Answers – Pointer to Structures 1.What is the output of this C code? #include <stdio.h> struct p { int x; char y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / 3); if (x ==…