Home / C Programming / Strings :: Find Output of Program

C Programming :: Strings

  1. What will be the output of the program ?

    #include 
    
     int main()
     {
         printf(5+"FresherGATE\n");  
         return 0; 
     } 
    

  2. A.

    Error

    B.

    FresherGATE

    C.

    GATE

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program ?

     #include
     #include 
    
     int main()
     {
         char sentence[80];   
         int i;   
         printf("Enter a line of text\n");   
         gets(sentence);     
         for(i=strlen(sentence)-1; i >=0; i--)         
            putchar(sentence[i]);   
         return 0; 
     } 
    

  4. A.

    The sentence will get printed in same order as it entered

    B.

    The sentence will get printed in reverse order

    C.

    Half of the sentence will get printed

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program ?

     #include
     void swap(char *, char *);  
    
     int main() 
     {   
         char *pstr[2] = {"Hello", "FresherGATE"};  
         swap(pstr[0], pstr[1]);    
         printf("%s\n%s", pstr[0], pstr[1]);    
         return 0;
     } 
     void swap(char *t1, char *t2)
     {   
         char *t;   
         t=t1;     
         t1=t2;   
         t2=t;
     }
    

     

  6. A.

    FresherGATE
    Hello

    B.

    Address of "Hello" and "FresherGATE"

    C.

    Hello
    Fres

    D.

    Iello
    HFresherGATE

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program (Turbo C in 16 bit platform DOS) ?

    
     #include
     #include 
    
      int main() 
      {    
          char *str1 = "Fresher";    
          char *str2 = "GATE";     
          char *str3;    
          str3 = strcat(str1, str2);     
          printf("%s %s\n", str3, str1);    
          return 0;
      } 
    

  8. A.

    FresherGATE Fresher

    B.

    FresherGATE FresherGATE

    C.

    Fresher Fresher

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. If the size of pointer is 4 bytes then What will be the output of the program ?

    #include 
    
     int main() 
     {   
         char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};   
         printf("%d, %d", sizeof(str), strlen(str[0]));    
         return 0;
     }
    

  10. A.

    22, 4

    B.

    25, 5

    C.

    24, 5

    D.

    20, 2

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program in Turbo C?

      #include
     
      int main() 
      {    
          char str[10] = "Fresher";    
          str[6] = "GATE";     
          printf("%s\n", str);     
          return 0;
      } 
    

  12. A.

    Fresher GATE

    B.

    GATE

    C.

    Fresher

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

     #include 
    
     int main()
     {   
         char str1[] = "Hello";  
         char str2[] = "Hello";  
         if(str1 == str2)          
             printf("Equal\n"); 
         else     
             printf("Unequal\n");     
        return 0; 
    } 
    

  14. A.

    Equal

    B.

    Unequal

    C.

    Error

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program ?

    #include  
    
     int main()
     {    
         char t;  
         char *p1 = "Fresher", *p2;    
         p2=p1;     
         p1 = "GATE";     
         printf("%s %s\n", p1, p2);   
         return 0;
     } 
    

  16. A.

    Fresher GATE

    B.

    GATE Fresher

    C.

     Fresher Fresher

    D.

    GATE GATE

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program ?

     #include
     #include  
    
      int main()
      {    
          printf("%c\n", "abcdefgh"[4]);     
          return 0;
      }
    

  18. A.

    Error

    B.

    d

    C.

    e

    D.

    abcdefgh

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the following program in 16 bit platform assuming that 1022 is memory address of the string "Hello1" (in Turbo C under DOS) ?

     #include 
    
     int main()
     {   
        printf("%u %s\n", &"Hello1", &"Hello2");      
        return 0;
     } 
    

  20. A.

    1022 Hello2

    B.

    Hello1 1022

    C.

    Hello1 Hello2

    D.

    1022 1022

    E.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum