C Programming - Library Functions

1.
Point out the error in the following program.
#include<stdio.h>

int main()
{
    fprintf("IndiaBIX");
    printf("%.ef", 2.0);
    return 0;
}
Error: unknown value in printf() statement.
Error: in fprintf() statement.
No error and prints "IndiaBIX"
No error and prints "2.0"
Answer: Option
Explanation:

Declaration Syntax:
int fprintf (FILE *stream, const char *format [, argument, ...]);

Example:
fprintf(filestream, "%s %d %s", Name, Age, City);


2.
Point out the error in the following program.
#include<stdio.h>
#include<string.h>

int main()
{
    char str1[] = "Learn through IndiaBIX\0.com",  str2[120];
    char *p;
    p = (char*) memccpy(str2, str1, 'i', strlen(str1));
    *p = '\0';
    printf("%s", str2);
    return 0;
}
Error: in memccpy statement
Error: invalid pointer conversion
Error: invalid variable declaration
No error and prints "Learn through Indi"
Answer: Option
Explanation:

Declaration:
void *memccpy(void *dest, const void *src, int c, size_t n); : Copies a block of n bytes from src to dest

With memccpy(), the copying stops as soon as either of the following occurs:
=> the character 'i' is first copied into str2
=> n bytes have been copied into str2


3.
Point out the error in the following program.
#include<stdio.h>

int main()
{
    char str[] = "IndiaBIX";
    printf("%.#s %2s", str, str);
    return 0;
}
Error: in Array declaration
Error: printf statement
Error: unspecified character in printf
No error
Answer: Option
Explanation:
No answer description is available. Let's discuss.