ExamTray App is now Available on Google Play EXAMTRAY android app link

 

00:00:00

C Programming Basics Tutorial - Strings, Char Arrays, Pointers - Online Test 2

Instructions

Total Questions: 20

Total Minutes: 20

This ExamTray Free Online Exam or MCQ Quiz tests your C Programming Skills on C Strings, Character Arrays and String Pointers. Examples are given as questions and answers. Easily Attend Competitive Exams and Job Interview Questions.

Go through C Theory Notes on Strings before attempting this test.

All the Best

1) What is the ASCII value of NULL or \0.?
2) A character constant is enclosed by.?
3) Choose a correct statement about C String.
4) A C string elements are always stored in.?
5) What is the output of C program with strings.?
int main()
{
    char var='b';
    printf("%d ", sizeof("a"));
    printf("%d ", sizeof('b'));
    printf("%d ", sizeof(10));
    printf("%d ", sizeof(var));
}
//int size is 2 bytes
6) What is the output of C program with strings.?
int main()
{
    char str[]="JACKIE CHAN";
    int i=0;
    while(str[i] != 0)
    {
        printf("%c",str[i]);
        i++;
    }
    return 0;
}
7) What is the output of C program with strings.?
int main()
{
    char str[]="ANDAMAN";
    int i=0;
    while(str[i] != '\0')
    {
        printf("%c",str[i]);
        i++;
    }
    return 0;
}
8) What is the output of C program with strings.?
int main()
{
    char str[]="MALDIVES";
    printf("%s ",str);
    puts(str);
    return 0;
}
9) What is the output of C program with strings.?
int main()
{
    char str[3]="SUNDAY";
    printf("%s",str);
}
10) Choose a correct C statement about String functions.?
11) Choose a correct C statement about String functions.?
12) Choose a correct C statement about String functions.?
13) What is the output of C program.?
int main()
{
    char str1[]="JAMES,";
    char str2[15]="BOND ";
    strcat(str2,str1);
    printf("%s",str2);
    printf("%s",str1);
}
14) What is the output of C program.?
int main()
{
    printf("%c","HUMPTY"[2]);
}
15) What is the output of C program.?
int main()
{
    char str1[] = "FIRST";
    char str2[20];
    strcpy(str2,str1);
    printf("%s %s ",str1,str2);
    printf("%d", (str1!=str2));
    printf("%d", strcmp(str1,str2));
    return 0;
}
16) What is the output of C program with array of pointers to strings.?
int main()
{
    char *code[]={"IN","USA","K"};
    printf("%s", code[1]);
    return 0;
}
17) What is the output of C program with String arrays.?
int main()
{
    char code[3][4]={"IN","USA","K"};
    printf("%s", code[1]);
    return 0;
}
18) What is the output of C program with array of pointers to strings.?
int main()
{
    char *code[2];
    code[0]= (char *)malloc(4);
    strcpy(code[0], "IND");
    printf("%s", code[0]);
    return 0;
}
19) What is actually passed to PRINTF or SCANF functions.?
20) What is the output of C program with strings.?
int main()
{
    char *code="JUMPER";
    if(code[6]=='\o')
    {
        printf("SUMMER");
    }
    else
    {
        printf("WINTER");
    }
    return 0;
}