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

C Programming :: Strings

  1. What will be the output of the program ?

    #include 
    
     int main() 
     {    
         static char s[25] = "The cocaine man";  
         int i=0;    
         char ch;    
         ch = s[++i];     
         printf("%c", ch);     
         chc= s[i++];  
         printf("%c", ch);   
         ch = i++[s];   
         printf("%c", ch);    
         ch = ++i[s];     
         printf("%c", ch);     
         return 0; 
    } 
    

     

  2. A.

    hhe!

    B.

    he c

    C.

    The c

    D.

    Hhec

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    #include 
    
     int main() 
     {  
       printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));   
       return 0;
     } 
    

  4. A.

    8, 1, 4

    B.

    4, 2, 8

    C.

    4, 2, 4

    D.

    10, 3, 4

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. If char=1, int=4, and float=4 bytes size, What will be the output of the program ?

     #include
     
      int main()
      {    
           char ch = 'A';   
           printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));     
           return 0; 
      } 
    
    

  6. A.

    1, 2, 4

    B.

    1, 4, 4

    C.

    2, 2, 4

    D.

    2, 4, 8

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. If the size of pointer is 32 bits What will be the output of the program ?

     #include 
    
     int main()
     {   
          char a[] = "Visual C++";  
          char *b = "Visual C++";     
          printf("%d, %d\n", sizeof(a), sizeof(b));      
          printf("%d, %d", sizeof(*a), sizeof(*b)); 
          return 0; 
      }
    

  8. A.

    10, 2
    2, 2

    B.

    10, 4
    1, 2

    C.

    11, 4
    1, 1

    D.

    12, 2
    2, 2

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program ?

     #include
    
      int main() 
      { 
        static char mess[6][30] = {"Don't walk in front of me...",                                   
                                  "I may not follow;",                                 
                                  "Don't walk behind me...",                                 
                                  "Just walk beside me...",                                 
                                  "And be my friend." };        
      printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
      return 0; 
    } 
    

  10. A.

    t, t

    B.

    k, k

    C.

    n, k

    D.

    m, f

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program ?

    #include 
    
     int main() 
     {   
          char str1[] = "Hello";   
          char str2[10];    
          char *t, *s;    
          s = str1;     
          t = str2;     
          while(*t=*s)       
              *t++ = *s++;     
          printf("%s\n", str2);     
          return 0; 
     } 
    

  12. A.

    Hello

    B.

    HelloHello

    C.

    No output

    D.

    ello

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program ?

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

  14. A.

    10

    B.

    6

    C.

    5

    D.

    11

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program ?

     #include 
    
     int main()
     {     
           char str[25] = "FresherGate";  
           printf("%s\n", &str+2);    
           return 0; 
     } 
    
    

  16. A.

    Garbage value

    B.

    Error

    C.

    No output

    D.

    diaGATE

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program ?

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

  18. A.

    Error

    B.

    FresherGATE

    C.

    Base address of str

    D.

    No output

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the program ?

     #include
    
      int main()
      {    
           char str[] = "Nagpur";  
           str[0]='K';     
           printf("%s, ", str);    
           str = "Kanpur";    
           printf("%s", str+1);     
           return 0;
      } 
    

  20. A.

    Kagpur, Kanpur

    B.

    Nagpur, Kanpur

    C.

    Kagpur, anpur

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum