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

C Programming :: Strings

  1. What will be the output of the program ?

     #include
     #include 
    
     int main() 
     {   
        char str1[20] = "Hello", str2[20] = " World";   
        printf("%s\n", strcpy(str2, strcat(str1, str2)));     
        return 0;
     } 
    

  2. A.

    Hello

    B.

    World

    C.

    Hello World

    D.

    WorldHello

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program ?

     #include
    
      int main()
      {     
          char p[] = "%d\n";   
          p[1] = 'c';    
          printf(p, 65); 
          return 0; 
    } 
    

  4. A.

    A

    B.

    a

    C.

    c

    D.

    65

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program ?

     #include
     #include
    
      int main()
      {
         printf("%d\n", strlen("123456"));                 
         return 0; 
      } 

     

  6. A.

    6

    B.

    12

    C.

    7

    D.

    2

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program ?

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

     

  8. A.

    Good Morning

    B.

    Good

    C.

    M

    D.

    Morning

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program ?

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

  10. A.

    GATE

    B.

    Fresher

    C.

    Fresher GATE

    D.

    Fresher\0GATE

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input?

    
    
    #include 
     int main() 
      {    
         void fun();   
         fun();     
         printf("\n");   
         return 0;
      }
      void fun() 
      {     
          char c;    
          if((c = getchar())!= '\n')                                           
          fun();   
          printf("%c", c); 
     } 
    

  12. A.

    abc abc

    B.

    bca

    C.

    Infinite loop

    D.

    cba

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

    #include 
     int main() 
     {  
          printf("Fresher, "GATE/n");     
          return 0; 
     } 

     

     

  14. A.

    Error

    B.

    Fresher  GATE

    C.

    Fresher

    D.

    GATE

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program ?

    #include 
     int main() 
     {   
        char str[7] = "FresherGATE";     
        printf("%s\n", str);   
        return 0; 
     } 
    

  16. A.

    Error

    B.

    FresherGATE

    C.

    Cannot predict

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program ?

    #include 
     int main() 
     {    
        char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"};    
        int i;    
        char *t;  
        t = names[3];    
        names[3] = names[4];   
        names[4] = t; 
        for(i=0; i4; i++)         
            printf("%s,", names[i]);   
        return 0; 
    } 
    

  18. A.

    Suresh, Siva, Sona, Baiju, Ritu

    B.

    Suresh, Siva, Sona, Ritu, Baiju

    C.

    Suresh, Siva, Baiju, Sona, Ritu

    D.

    Suresh, Siva, Ritu, Sona, Baiju

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the program ?

     #include
     #include 
    
     int main()
     {
         char str[] = "Fresher0\GATE\0";     
         printf("%d\n", strlen(str));     
         return 0;
     } 
    

  20. A.

    10

    B.

    6

    C.

    5

    D.

    11

    View Answer

    Workspace

    Discuss Discuss in Forum