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 1

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.

All the Best

1) What is a String in C Language.?
2) Choose a correct statement about C String.
char ary[]="Hello..!";
3) What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?
4) What is the output of C Program with Strings.?
int main()
{
    char ary[]="Discovery Channel";
    printf("%s",ary);
    return 0;
}
5) What is the output of C Program with Strings.?
int main()
{
    char str[]={'g','l','o','b','e'};
    printf("%s",str);
    return 0;
}
6) What is the output of C Program with Strings.?
int main()
{
    char str[]={'g','l','o','b','y','\0'};
    printf("%s",str);
    return 0;
}
7) How do you convert this char array to string.?
char str[]={'g','l','o','b','y'};
8) What is the output of C Program.?
int main()
{
    int str[]={'g','l','o','b','y'};
    printf("A%c ",str);
    printf("A%s ",str);
    printf("A%c ",str[0]);
    return 0;
}
9) What is the output of C Program with arrays.?
int main()
{
    char str[]={"C","A","T","\0"};
    printf("%s",str);
    return 0;
}
10) What is the maximum length of a C String.?
11) What is the output of C program with strings.?
int main()
{
    char str1[]="JOHN";
    char str2[20];
    str2= str1;
    printf("%s",str2);
    return 0;
}
12) What is the output of C Program with arrays.?
int main()
{
    char str[25];
    scanf("%s", str);
    printf("%s",str);
    return 0;
}
//input: South Africa
13) What is the output of C program with strings.?
int main()
{
    char str[2];
    scanf("%s", str);
    printf("%s",str);
    return 0;
}
//Input: South
14) What is the output of C Program with strings.?
int main()
{
    char str[2];
    int i=0;
    scanf("%s", str);
    while(str[i] != '\0')
    {
        printf("%c", str[i]);
        i++;
    }
    return 0;
}
//Input: KLMN
15) What is the output of C Program with String Pointer.?
int main()
{
    char country[]="BRAZIL";
    char *ptr;
    ptr=country;
    while(*ptr != '\0')
    {
        printf("%c", *ptr);
        ptr++;
    }
    return 0;
}
16) How do you accept a Multi Word Input in C Language.?
17) Choose a correct C Statement about Strings.
18) What is the output of C Program with String Pointers.?
int main()
{
    char *p1 = "GOAT";
    char *p2;
    p2 = p1;
    printf("%s", p2);
}
19) What is the output of C Program with String arrays.?
int main()
{
    char *p1 = "GOAT";
    char *p2;
    p2 = p1;
    p2="ANT";
    printf("%s", p1);
}
20) What is the output of C Program with String Arrays.?
int main()
{
    char p[] = "GODZILLA";
    int i=0;
    while(p[i] != '\0')
    {
        printf("%c",*(p+i));
        i++;
    }
}