• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Quiz - 108

Question 1

In the below statement, ptr1 and ptr2 are uninitialized pointers to int i.e. they are pointing to some random address that may or may not be valid address. C
int* ptr1, ptr2;
  • TRUE
  • FALSE

Question 2

Anyone of the followings can be used to declare a node for a singly linked list. If we use the first declaration, “struct node * nodePtr;” would be used to declare pointer to a node. If we use the second declaration, “NODEPTR nodePtr;” can be used to declare pointer to a node. C
/* First declaration */
struct node {
int data;
struct node * nextPtr;
};

/* Second declaration */
typedef struct node{
int data;
NODEPTR nextPtr;
} * NODEPTR;
  • TRUE
  • FALSE

Question 3

Anyone of the following can be used to declare a node for a singly linked list and “NODEPTR nodePtr;” can be used to declare pointer to a node using any of the following C
/* First declaration */
typedef struct node
{
 int data;
 struct node *nextPtr;
}* NODEPTR;

/* Second declaration */
struct node
{
 int data;
 struct node * nextPtr;
};
typedef struct node * NODEPTR;
  • TRUE
  • FALSE

Question 4

Both of the following declarations for function pointers are equivalent. Second one (i.e. with typedef) looks cleaner. C
/* First Declaration */
int (*funPtr1)(int), (*funPtr2)(int);

/* Second Declaration*/
typedef int (*funPtr)(int);
funPtr funPtr1, funPtr2;
  • TRUE
  • FALSE

Question 5

In a C file (say sourcefile1.c), an array is defined as follows. Here, we don’t need to mention array arr size explicitly in [] because the size would be determined by the number of elements used in the initialization. C
int arr[] = {1,2,3,4,5};
In another C file (say sourcefile2.c), the same array is declared for usage as follows: C
extern int arr[];
In sourcefile2.c, we can use sizeof() on arr to find out the actual size of arr.
  • TRUE
  • FALSE

Question 6

Choose the correct option to fill the ?1 and ?2 so that the program prints an input string in reverse order. Assume that the input string is terminated by a new line character.
#include <stdio.h>
void wrt_it (void);
int main (void)
{
    printf("Enter Text"); 
    printf ("\\n");
    wrt_ it();
    printf ("\\n");
    return 0;
}
void wrt_it (void)
{
    int c;
    if (?1)
        wrt_it();
    ?2
}
  • ?1 is  getchar() ! = \'\\n\' ?2 is  getchar(c);
  • ?1 is  (c = getchar()); ! = \'\\n\' ?2 is  getchar(c);
  • ?1 is  c! = \'\\n\' ?2 is  putchar(c);
  • ?1 is (c = getchar()) ! = \'\\n\' ?2 is putchar(c);

There are 6 questions to complete.

Last Updated :
Take a part in the ongoing discussion