My Report

C Programming Practice Test 8


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. The______function returns a pointer to the first character of a token.

2. HUGE_VAL macro is used when the output of the function may not be ___________

3. What will be the output of the following C code?

errno = 0;
y = sqrt(-10);
if(errno == EDOM)
printf("Invalid value \n");
else
printf("Valid value\n");

4. What will be the output of the following C code?

#include<stdio.h>
int main()
{
    typedef union a
    {
        int i;
        char ch[2];
    }hello;
    hello u;
    u.ch[0] = 3;
    u.ch[1] = 2;
    printf("%d, %d", u.ch[0], u.ch[1]);
    return 0;
}

5. The isdigit function tests for any decimal-digit character.

6. What will be the output of the following C code?

    #include <stdio.h>
    union temp
    {
        char a;
        char b;
        int c;
    }t;
    int main()
    {
        printf("%d", sizeof(t));
        return 0;
    } 

7. What will be the output of the following C code?

char ch[ ] = "0xC";
if(isxdigit(ch[ ]))
printf("ch = %s is hexadecimal character \n",ch);
else
printf("ch = %s is not hexadecimal character \n",ch);

8. The______ function returns the number of characters that are present before the terminating null character.

9. What will be the output of the following C code?

const char str1[]="ABCDEF1234567";
const char str2[] = "269";
len = strcspn(str1, str2);
printf("First matching character is at %d\n", len + 1);

10. isalpha() function is used to detect characters both in uppercase and lowercase.


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.