My Courses
C Programming Questions and Answers – Arrays of Structures
C Programming Questions and Answers – Arrays of Structures 1.The correct syntax to access the member of the ith structure in the array of structures is? Assuming: struct temp { int b; }s[50]; a) s.b.[i]; b) s.[i].b; c) s.b[i]; d) s[i].b; 2.Comment on the output of this C code? #include <stdio.h> struct temp { int…
C Programming Questions and Answers – Structures and Functions
C Programming Questions and Answers – Structures and Functions 1.What is the output of this C code? #include <stdio.h> struct student { char *name; }; struct student s; struct student fun(void) { s.name = “newton”; printf(“%s\n”, s.name); s.name = “alan”; return s; } void main() { struct student m = fun(); printf(“%s\n”, m.name); m.name…
C Programming Questions and Answers – Basics of Structures
C Programming Questions and Answers – Basics of Structures 1.Which of the following are themselves a collection of different data types? a) string b) structures c) char d) All of the mentioned 2.User-defined data type can be derived by___________. a) struct b) enum c) typedef d) All of the mentioned 3.Which operator connects…
C Programming Questions and Answers – Complicated Declarations
C Programming Questions and Answers – Complicated Declarations 1.What is the output of this C code? #include <stdio.h> void main() { struct student { int no; char name[20]; }; struct student s; no = 8; printf(“%d”, no); } a) Nothing b) Compile time error c) Junk d) 8 2.What is the output of…
C Programming Questions and Answers – Pointers to Functions
C Programming Questions and Answers – Pointers to Functions 1.Which function is not called in the following program? #include <stdio.h> void first() { printf(“first”); } void second() { first(); } void third() { second(); } void main() { void (*ptr)(); ptr = third; ptr(); } a) Function first b) Function second c) Function third…
C Programming Questions and Answers – Command Line Arguments
C Programming Questions and Answers – Command Line Arguments 1.What does argv and argc indicate in command-line arguments? (Assuming: int main(int argc, char *argv[]) ) a) argument count, argument variable b) argument count, argument vector c) argument control, argument variable d) argument control, argument vector 2.Which of the following syntax is correct for command-line…
C Programming Questions and Answers – Pointers Vs. Multi-dimensional Arrays
C Programming Questions and Answers – Pointers Vs. Multi-dimensional Arrays 1.int a[10][20]; which is true for a a) a is true two-dimensional array b) 200 int-sized locations have been set aside c) The conventional rectangular subscript calculation 20 * row + col is used to find the element a[row, col] d) All of the…
C Programming Questions and Answers – Initialization of Pointer Arrays
C Programming Questions and Answers – Initialization of Pointer Arrays 1.To declare a 3 dimension array using pointers, which of the following is the correct syntax: a) char *a[][]; b) char **a[]; c) char ***a; d) All of the mentioned 2.Comment on the output of this C code? #include <stdio.h> int main() { char…
C Programming Questions and Answers – Multidimensional Arrays
C Programming Questions and Answers – Multidimensional Arrays 1.What is the output of this C code? #include <stdio.h> void main() { int a[2][3] = {1, 2, 3, 4, 5}; int i = 0, j = 0; for (i = 0; i < 2; i++) for (j = 0; j < 3; j++) printf(“%d”, a[i][j]);…
C Programming Questions and Answers – Pointers to Pointers
C Programming Questions and Answers – Pointers to Pointers 1.What is the output of this C code? #include <stdio.h> void main() { int k = 5; int *p = &k; int **m = &p; printf(“%d%d%d\n”, k, *p, **m); } a) 5 5 5 b) 5 5 junk value c) 5 junk junk d)…