Q. What is a C FILE data type?

  • (A) FILE is like a Structure only
  • (B) FILE is like a Union only
  • (C) FILE is like a user define int data type
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) FILE is like a Structure only

Q. Where is a file temporarily stored before read or write operation in C language?

  • (A) Buffer
  • (B) Hard disk
  • (C) RAM
  • (D) Notepad
πŸ’¬ Discuss
βœ… Correct Answer: (A) Buffer

Q. Choose a correct statement about C file operation program?

Code:
int main()
{
    FILE *fp;
    char ch;
    fp=fopen("readme.txt","r");
    while((ch=fgetc(fp)) != EOF)
    {
        printf("%c",ch);
    }
}
  • (A) FOPEN opens a file named readme.txt in Read Mode ("r).
  • (B) EOF is End Of File. ch==EOF checks for end of file and while loop stops or exits.
  • (C) FGETC(fp) is a function that returns one character and cursor goes to next character.
  • (D) All the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All the above

Q. What is the need for closing a file in C language?

  • (A) fclose(fp) closes a file to release the memory used in opening a file.
  • (B) Closing a file clears Buffer contents from RAM or memory.
  • (C) Unclosed files occupy memory and PC hangs when on low memory.
  • (D) All the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All the above

Q. If a FILE pointer is NULL what does it mean?

Code:
FILE *fp;
fp=fopen("abc.txt","w");
  • (A) Unable to open a file named abc.txt
  • (B) abc.txt is not available on disk
  • (C) Hard disk has hard ware problems.
  • (D) All the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All the above

Q. Choose a correct statement about FGETS in C program

Code:
int main()
{
    FILE *fp;
    char str[80];
    fp=fopen("readme.txt","r");
    while(fgets(str,80,fp) != NULL)
    {
        printf("%s",str);
    }
    fclose(fp);
}
  • (A) str in fgets() is a like a user buffer that can store 80 characters each time
  • (B) FGETS returns null if no characters are left
  • (C) fgets() reads content from File. FPUS writes content back to File.
  • (D) All the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All the above

Q. Choose a correct statement about C String.

Code:
char ary[]="Hello..!";
  • (A) String can not contain special characters.
  • (B) String size is not mentioned
  • (C) ary has no Null character at the end
  • (D) Character array, ary is a string.
πŸ’¬ Discuss
βœ… Correct Answer: (D) Character array, ary is a string.

Q. What is the output of C Program with Strings?

Code:
int main()
{
    char ary[]="Discovery Channel";
    printf("%s",ary);
    return 0;
}
  • (A) D
  • (B) Discovery
  • (C) Discovery Channel
  • (D) Compiler error
πŸ’¬ Discuss
βœ… Correct Answer: (C) Discovery Channel

Q. What is the output of C Program with Strings?

Code:
int main()
{
    char str[]={'g','l','o','b','e'};
    printf("%s",str);
    return 0;
}
  • (A) g
  • (B) globe\0
  • (C) globe
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) None of the above

Q. What is the output of C Program with Strings.?

Code:
int main()
{
    char str[]={'g','l','o','b','y','\0'};
    printf("%s",str);
    return 0;
}
  • (A) g
  • (B) globe\0
  • (C) globe
  • (D) Compiler error
πŸ’¬ Discuss
βœ… Correct Answer: (C) globe