What will be the output of the following C code?#include int main(){char c;int i = 0;FILE *file;file = fopen("test.txt", "w+");fprintf(file, "%c", 'a');fprintf(file, "%c", -1);fprintf(file, "%c", 'b');fclose(file);file = fopen("test.txt", "r");while ((c = fgetc(file)) != -1)printf("%c", c);return 0;}

🎲 Try a Random Question  |  Total Questions in Quiz: 211  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
C Programming Practice Test: Data Types, Operators and Expressions — practice the complete quiz, review flashcards, or try a random question.

Quiz questions on: Variable names, datatypes, constants, declarations, arithmetic operators, relational and logical operators, type conversions, bitwise operators, assignment operators, increment and decrement operators, conditional expressions, evaluation order and precedence. Data Types C has four basic data types: Char: This data type stores a single character. It can be signed or unsigned. Int: This data type stores an integer. It can be signed or unsigned. Float: This data type stores a floating-point number. Double: This data type stores a double-precision floating-point... Show more

What will be the output of the following C code?<br>#include <stdio.h><br>int main()<br>{<br>char c;<br>int i = 0;<br>FILE *file;<br>file = fopen("test.txt", "w+");<br>fprintf(file, "%c", 'a');<br>fprintf(file, "%c", -1);<br>fprintf(file, "%c", 'b');<br>fclose(file);<br>file = fopen("test.txt", "r");<br>while ((c = fgetc(file)) != -1)<br>printf("%c", c);<br>return 0;<br>}