Home / C Programming / Input / Output :: Point Out Errors

C Programming :: Input / Output

  1. Point out the error in the program?

      #include
      int main()
      {    
           char ch;    
           int i;   
           scanf("%c", &i);     
           scanf("%d", &ch);     
           printf("%c %d", ch, i);     
           return 0;
     } 
    

     

  2. A.

    Error: suspicious char to in conversion in scanf()

    B.

    Error: we may not get input for second scanf() statement

    C.

    No error

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Point out the error in the program?

     #include 
     int main()
     {    
          FILE *fp;  
          fp=fopen("trial", "r");     
          fseek(fp, "20", SEEK_SET);     
          fclose(fp);  
          return 0; 
    } 
    

  4. A.

    Error: unrecognised Keyword SEEK_SET

    B.

    Error: fseek() long offset value

    C.

    No error

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Point out the error in the program?

     #include 
     /* Assume there is a file called 'file.c' in c:\tc directory. */
     int main()
     {    
           FILE *fp;      
           fp=fopen("c:\tc\file.c", "r");         
           if(!fp)   
              printf("Unable to open file.");          
           fclose(fp);   
           return 0; 
    }
    

  6. A.

    No error, No output.

    B.

    Program crashes at run time.

    C.

    Output: Unable to open file.

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Point out the error/warning in the program?

     #include
    
      int main()
      {
         unsigned char ch;   
         FILE *fp;  
         fp=fopen("trial", "r");     
         while((ch = getc(fp))!=EOF)         
             printf("%c", ch);     
         fclose(fp); 
         return 0; 
     } 
    

  8. A.

    Error: in unsigned char declaration

    B.

    Error: while statement

    C.

    No error

    D.

    It prints all characters in file "trial"

    View Answer

    Workspace

    Discuss Discuss in Forum