Blind Coding C Programming Practice Quiz!

50 Questions | Total Attempts: 55

SettingsSettingsSettings
Please wait...
Blind Coding C Programming Practice Quiz!

.


Questions and Answers
  • 1. 
    What will be the output of the program? #include #include int main() {     float n=1.54;     printf("%f, %f\n", ceil(n), floor(n));     return 0; }  
    • A. 

      2.000000, 1.000000

    • B. 

      1.500000, 1.500000

    • C. 

      1.550000, 2.000000

    • D. 

      1.000000, 2.000000

  • 2. 
    What will be the output of the program? #include int main() {     float d=2.25;     printf("%e,", d);     printf("%f,", d);     printf("%g,", d);     printf("%lf", d);     return 0; }  
    • A. 

      2.2, 2.50, 2.50, 2.5

    • B. 

      2.2e, 2.25f, 2.00, 2.25

    • C. 

      2.250000e+000, 2.250000, 2.25, 2.250000

    • D. 

      Error

  • 3. 
    Point out the error in the program #include int main() {     int i;     #if A         printf("Enter any number:");         scanf("%d", &i);     #elif B         printf("The number is odd");     return 0; }  
    • A. 

      Error: unexpected end of file because there is no matching #endif

    • B. 

      The number is odd

    • C. 

      Garbage values

    • D. 

      None of above

  • 4. 
    What will be the output of the program (Turbo C in 16-bit platform DOS)? #include #include   int main() {     char *str1 = "India";     char *str2 = "BIX";     char *str3;     str3 = strcat(str1, str2);     printf("%s %s\n", str3, str1);     return 0; }  
    • A. 

      IndiaBIX India

    • B. 

      IndiaBIX IndiaBIX

    • C. 

      India India

    • D. 

      Error

  • 5. 
    Which of the following statements correct about the below program? #include int main() {     union a     {         int i;         char ch[2];     };     union a u1 = {512};     union a u2 = {0, 2};     return 0; } 1:         u2 CANNOT be initialized as shown. 2:         u1 can be initialized as shown. 3:         To initialize char ch[] of u2 '.' operator should be used. 4:         The code causes an error 'Declaration syntax error'  
    • A. 

      1, 2

    • B. 

      2, 3

    • C. 

      1, 2, 3

    • D. 

      1, 3, 4

  • 6. 
    What will be the output of the program? #include int get(); int main() {     const int x = get();     printf("%d", x);     return 0; } int get() {     return 20; }  
    • A. 

      Garbage value

    • B. 

      Error

    • C. 

      20

    • D. 

      0

  • 7. 
    Point out the error in the program.   #include   #include   int fun(const union employee *e);   union employee {     char name[15];     int age;     float salary; }; const union employee e1;   int main() {     strcpy(e1.name, "A");     fun(&e1);     printf("%s %d %f", e1.name, e1.age, e1.salary);     return 0; } int fun(const union employee *e) {     strcpy((*e).name, "B");     return 0; }  
    • A. 

      Error: RValue required

    • B. 

      Error: cannot convert parameter 1 from 'const char[15]' to 'char *'

    • C. 

      Error: LValue required in strcpy

    • D. 

      No error

  • 8. 
    Point out the error in the following program. #include void display(int (*ff)()); int main() {     int show();     int (*f)();     f = show;     display(f);     return 0; } void display(int (*ff)()) {     (*ff)(); } int show() {     printf("IndiaBIX"); }  
    • A. 

      Error: invalid parameter in function display()

    • B. 

      Error: invalid function call f=show;

    • C. 

      No error and prints "IndiaBIX"

    • D. 

      No error and prints nothing.

  • 9. 
    Point out the error, if any in the program. #include int main() {     int a = 10, b;     a >=5 ? b=100: b=200;     printf("%d\n", b);     return 0; }  
    • A. 

      100

    • B. 

      200

    • C. 

      Error: L value required for b

    • D. 

      Garbage value

  • 10. 
    What will be the output of the program? #include int main() {     int i=4, j=-1, k=0, w, x, y, z;     w = i || j || k;     x = i && j && k;     y = i || j &&k;     z = i && j || k;     printf("%d, %d, %d, %d\n", w, x, y, z);     return 0; }  
    • A. 

      1, 1, 1, 1

    • B. 

      1, 1, 0, 1

    • C. 

      1, 0, 0, 1

    • D. 

      1, 0, 1, 1

  • 11. 
     Macros have a local scope.
    • A. 

      True

    • B. 

      False

  • 12. 
    Is this a correct way for NULL pointer assignment? int i=0; char *q=(char*)i;  
    • A. 

      Yes

    • B. 

      No

  • 13. 
    What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes? #include   int main() {     int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};     printf("%u, %u\n", a+1, &a+1);     return 0; }  
    • A. 

      65474, 65476

    • B. 

      65480, 65496

    • C. 

      65480, 65488

    • D. 

      65474, 65488

  • 14. 
    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; }  
    • 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

  • 15. 
    What will be the output of the program ? #include       struct course     {         int courseno;         char coursename[25];     }; int main() {     struct course c[] = { {102, "Java"},                           {103, "PHP"},                           {104, "DotNet"}     };       printf("%d ", c[1].courseno);     printf("%s\n", (*(c+2)).coursename);     return 0; }  
    • A. 

      103 DotNet

    • B. 

      103 PHP

    • C. 

      102 Java

    • D. 

      104 DotNet

  • 16. 
    On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"? #include   int main() {     int i, fss;     char ch, source[20] = "source.txt", target[20]="target.txt", t;     FILE *fs, *ft;     fs = fopen(source, "r");     ft = fopen(target, "w");     while(1)     {         ch=getc(fs);         if(ch==EOF)             break;         else         {             fseek(fs, 4L, SEEK_CUR);             fputc(ch, ft);         }     }     return 0; }  
    • A. 

      R n

    • B. 

      Trh

    • C. 

      Err

    • D. 

      None of above

  • 17. 
    What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)? cmd> sample 1 2 3 /* sample.c */ #include   int main(int argc, char *argv[]) {     int j;     j = argv[1] + argv[2] + argv[3];     printf("%d", j);     return 0; }  
    • A. 

      6

    • B. 

      Sample 6

    • C. 

      Error

    • D. 

      Garbage value

  • 18. 
    What will be the output of the program? #include int main() {     int x=1, y=1;     for(; y; printf("%d %d\n", x, y))     {         y = x++ <= 5;     }     printf("\n");     return 0; }  
    • A. 

      A. 2 1 3 1 4 1 5 1 6 1 7 0

    • B. 

      B. 2 1 3 1 4 1 5 1 6 1

    • C. 

      C. 2 1 3 1 4 1 5 1

    • D. 

      D. 2 2 3 3 4 4 5 5

  • 19. 
    Which of the following range is a valid long double (Turbo C in 16 bit DOS OS) ?  
    • A. 

      3.4E-4932 to 1.1E+4932

    • B. 

      3.4E-4932 to 3.4E+4932

    • C. 

      1.1E-4932 to 1.1E+4932

    • D. 

      1.7E-4932 to 1.7E+4932

  • 20. 
    What will be the output of the program? #include #include   int main() {     int i=0;     i++;     if(i<=5)     {         printf("IndiaBIX");         exit(1);         main();     }     return 0; }  
    • A. 

      Prints "IndiaBIX" 5 times

    • B. 

      Function main() doesn't calls itself

    • C. 

      Infinite loop

    • D. 

      Prints "IndiaBIx"

  • 21. 
    What will be the output of the program ? #include   int main() {     int i, a[] = {2, 4, 6, 8, 10};     change(a, 5);     for(i=0; i<=4; i++)         printf("%d, ", a[i]);     return 0; } void change(int *b, int n) {     int i;     for(i=0; i        *(b+1) = *(b+i)+5; }            
    • A. 

      7, 9, 11, 13, 15

    • B. 

      2, 15, 6, 8, 10

    • C. 

      2 4 6 8 10

    • D. 

      3, 1, -1, -3, -5

  • 22. 
    What will be the output of the program ? #include   int main() {     enum status {pass, fail, absent};     enum status stud1, stud2, stud3;     stud1 = pass;     stud2 = absent;     stud3 = fail;     printf("%d %d %d\n", stud1, stud2, stud3);     return 0; }  
    • A. 

      0, 1, 2

    • B. 

      1, 2, 3

    • C. 

      0, 2, 1

    • D. 

      1, 3, 2

  • 23. 
    Which of the following statements are correct about the program? #include char *fun(unsigned int num, int base);   int main() {     char *s;     s=fun(128, 2);     s=fun(128, 16);     printf("%s\n",s);     return 0; } char *fun(unsigned int num, int base) {     static char buff[33];     char *ptr = &buff[sizeof(buff)-1];     *ptr = '\0';     do     {         *--ptr = "0123456789abcdef"[num %base];         num /=base;     }while(num!=0);     return ptr; }  
    • A. 

      It converts a number to a given base

    • B. 

      It converts a number to its equivalent binary.

    • C. 

      It converts a number to its equivalent hexadecimal.

    • D. 

      It converts a number to its equivalent octal.

  • 24. 
    Point out the correct statement will let you access the elements of the array using 'p' in the following program? #include #include   int main() {     int i, j;     int(*p)[3];     p = (int(*)[3])malloc(3*sizeof(*p));     return 0; }  
    • A. 

      For(i=0; i

    • B. 

      For(i=0; i

    • C. 

      For(i=0; i

    • D. 

      For(j=0; j

  • 25. 
    Point out the error in the following program. #include #include   int main() {     char str1[] = "Learn through IndiaBIX\0.com",  str2[120];     char *p;     p = (char*) memccpy(str2, str1, 'i', strlen(str1));     *p = '\0';     printf("%s", str2);     return 0; }  
    • A. 

      Error: in memccpy statement

    • B. 

      Error: invalid pointer conversion

    • C. 

      Error: invalid variable declaration

    • D. 

      No error and prints "Learn through Indi"

Back to Top Back to top