logo

CuriousTab

CuriousTab

Discussion


Home C Programming Strings Comments

  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        char str = "CuriousTab";
        printf("%s\n", str);
        return 0;
    }
    


  • Options
  • A. Error
  • B. CuriousTab
  • C. Base address of str
  • D. No output

  • Correct Answer
  • Error 

    Explanation
    The line char str = "CuriousTab"; generates "Non portable pointer conversion" error.

    To eliminate the error, we have to change the above line to

    char *str = "CuriousTab"; (or) char str[] = "CuriousTab";

    Then it prints "CuriousTab".


    Strings problems


    Search Results


    • 1. What will be the output of the program?
      #include<stdio.h>
      
      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;
      }
      

    • Options
    • A. Hello
    • B. HelloHello
    • C. No output
    • D. ello
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf(5+"Good Morning\n");
          return 0;
      }
      

    • Options
    • A. Good Morning
    • B. Good
    • C. M
    • D. Morning
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char p[] = "%d\n";
          p[1] = 'c';
          printf(p, 65);
          return 0;
      }
      

    • Options
    • A. A
    • B. a
    • C. c
    • D. 65
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char str[] = "Nagpur";
          str[0]='K';
          printf("%s, ", str);
          str = "Kanpur";
          printf("%s", str+1);
          return 0;
      }
      

    • Options
    • A. Kagpur, Kanpur
    • B. Nagpur, Kanpur
    • C. Kagpur, anpur
    • D. Error
    • Discuss
    • 5. If the size of pointer is 4 bytes then What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
          printf("%d, %d", sizeof(str), strlen(str[0]));
          return 0;
      }
      

    • Options
    • A. 22, 4
    • B. 25, 5
    • C. 24, 5
    • D. 20, 2
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf(5+"CuriousTab\n");
          return 0;
      }
      

    • Options
    • A. Error
    • B. CuriousTab
    • C. CURIOUSTAB
    • D. None of above
    • Discuss
    • 7. What will be the output of the program?
      #include<stdio.h>
      #include<string.h>
      
      int main()
      {
          static char str1[] = "dills";
          static char str2[20];
          static char str3[] = "Daffo";
          int i;
          i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
          printf("%d\n", i);
          return 0;
      }
      

    • Options
    • A. 0
    • B. 1
    • C. 2
    • D. 4
    • Discuss
    • 8. If char=1, int=4, and float=4 bytes size, What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char ch = 'A';
          printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
          return 0;
      }
      

    • Options
    • A. 1, 2, 4
    • B. 1, 4, 4
    • C. 2, 2, 4
    • D. 2, 4, 8
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char t;
          char *p1 = "India", *p2;
          p2=p1;
          p1 = "CURIOUSTAB";
          printf("%s %s\n", p1, p2);
          return 0;
      }
      

    • Options
    • A. India CURIOUSTAB
    • B. CURIOUSTAB India
    • C. India India
    • D. CURIOUSTAB CURIOUSTAB
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char str[] = "India\0CURIOUSTAB\0";
          printf("%d\n", sizeof(str));
          return 0;
      }
      

    • Options
    • A. 10
    • B. 6
    • C. 5
    • D. 11
    • Discuss


    Comments

    There are no comments.

Enter a new Comment