Home / C Programming / Input / Output :: Discussion

Discussion :: Input / Output

  1. Which of the following statement is correct about the program?

    #include 
    
     int main() 
     {  
        FILE *fp;  
        char str[11], ch;  
        int i=0;    
        fp = fopen("INPUT.TXT", "r");     
        while((ch=getc(fp))!=EOF) 
        {       
           if(ch == '\n' || ch == ')         
           {
             str[i]='\0';             
             strrev(str);             
             printf("%s", str);             
             i=0;     
          }     
          else        
             str[i++]=ch;    
         }     
         fclose(fp);   
          return 0;
      } 
    

  2. A.

    The code writes a text to a file

    B.

    The code reads a text files and display its content in reverse order

    C.

    The code writes a text to a file in reverse order

    D.

    None of above

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    This program reads the file INPUT.TXT and store it in the string str after reversing the string using strrev function.


Be The First To Comment