Yes / No Questions

Question 1 :

Is standard library a part of C language?


A). Yes
B). No
Answer : Option B

Explanation :

The C standard library consists of a set of sections of the ISO C standard which describe a collection of header files and library routines used to implement common operations, such as input/output and string handling, in the C programming language. The C standard library is an interface standard described by a document; it is not an actual library of software routines available for linkage to C programs.


Question 2 :

Will the program outputs "IndiaPARINAM.com"?

#include < stdio . h >
#include < string . h >
int main()
{
    char str1[] = "IndiaPARINAM.com";
    char str2[20];
    strncpy(str2, str1, 8);
    printf("%s", str2);
    return 0;
}


A). Yes
B). No
Answer : Option B

Explanation :

No. It will print something like 'IndiaPARINAM(some garbage values here)' .

Because after copying the first 8 characters of source string into target string strncpy() doesn't terminate the target string with a '\0'. So it may print some garbage values along with IndiaPARINAM.


Question 3 :

The itoa function can convert an integer in decimal, octal or hexadecimal form to a string.


A). Yes
B). No
Answer : Option A

Explanation :

itoa() takes the integer input value input and converts it to a number in base radix. The resulting number a sequence of base-radix digits.

Example:

/* itoa() example */
#include < stdio . h >
#include < stdlib .h >
int main ()
{
    int no;
    char buff [50];
    printf ("Enter number: ");
    scanf ("%d",&no);
    
    itoa (no,buff,10);
    printf ("Decimal: %s\n",buff);
    
    itoa (no,buff,2);
    printf ("Binary: %s\n",buff);
    
    itoa (no,buff,16);
    printf ("Hexadecimal: %s\n",buff);
    
    return 0;
}
Output:
Enter a number: 1250
Decimal: 1250
Binary: 10011100010
Hexadecimal: 4e2


Question 4 :

The prototypes of all standard library string functions are declared in the file string.h.


A). Yes
B). No
Answer : Option A

Explanation :

string.h is the header in the C standard library for the C programming language which contains macro definitions, constants, and declarations of functions and types used not only for string handling but also various memory handling functions.


Question 5 :

scanf() or atoi() function can be used to convert a string like "436" in to integer.


A). Yes
B). No
Answer : Option A

Explanation :

scanf is a function that reads data with specified format from a given string stream source.
scanf("%d",&number);

atoi() convert string to integer.
var number;
number = atoi("string");