CPP

CPP

C Input Output has 9 Questions

Which header file is used with input and output operations of C in C++?

stdio.h
cstdio
iostream
None of the mentioned
Which will be used with physical devices to interact from C++ program?

Programs
Library
Streams
None of the mentioned
How many streams are automatically created when executing a program?

1
2
3
4
What is the output of this program by manipulating the text file?
  1.     #include 
  2.     int main () 
  3.     {
  4.         if (remove( "myfile.txt" ) != 0 )
  5.             perror( "Error" );
  6.         else
  7.             puts( "Success" );
  8.         return 0;
  9.     }

Error
Success
Runtime Error
Can't say
What is the output of this program in the text file?
  1.     #include 
  2.     int main ()
  3.     {
  4.         FILE * pFile;
  5.         char c;
  6.         pFile = fopen("sample.txt", "wt");
  7.         for (c = 'A'; c <= 'E'; c++) 
  8.         {    
  9.             putc (c, pFile);
  10.         }
  11.         fclose (pFile);
  12.         return 0;
  13.     }

ABCD
ABC
ABCDE
None of the mentioned
What is the name of the myfile2 file after executing this program?
  1.     #include 
  2.     int main ()
  3.     {
  4.         int result;
  5.         char oldname[] = "myfile2.txt";
  6.         char newname[] = "newname.txt";
  7.         result = rename(oldname, newname );
  8.         if (result == 0)
  9.             puts ( "success" );
  10.         else
  11.             perror( "Error" );
  12.         return 0;
  13.     }


name
new
newname
None of the mentioned
How many number of characters are available in newname.txt?
  1.     #include 
  2.     int main ()
  3.     {
  4.         FILE * p;
  5.         int n = 0;
  6.         p = fopen ("newname.txt", "rb");
  7.         if (p == NULL) 
  8.             perror ("Error opening file");
  9.         else
  10.         {
  11.             while (fgetc(p) != EOF)
  12.             {
  13.                 ++n;
  14.             }
  15.             if (feof(p)) 
  16.             {
  17.                 printf ("%d\n", n);
  18.             }
  19.             else
  20.                 puts ("End-of-File was not reached.");
  21.             fclose (p);
  22.         }
  23.         return 0;
  24.     }

10
15
Depends on the text file
None of the mentioned
What is the benefit of c++ input and output over c input and output?

Type safety
Exception
Both a & b
None of the mentioned
How many indicators are available in c++?

4
3
2
1