[go: up one dir, main page]

0% found this document useful (0 votes)
57 views2 pages

C String Functions and Outputs Explained

The document contains a series of questions and answers related to string handling in C programming. It covers various functions, their outputs, and characteristics of strings, including memory allocation and comparisons. The content is structured in a question-and-answer format, with options provided for each question.

Uploaded by

diyadivya528
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

C String Functions and Outputs Explained

The document contains a series of questions and answers related to string handling in C programming. It covers various functions, their outputs, and characteristics of strings, including memory allocation and comparisons. The content is structured in a question-and-answer format, with options provided for each question.

Uploaded by

diyadivya528
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd

Question Option A

What is a string in C? An array of integers


What is the size of the string "HELLO" stored as char s[] = "HELLO";? 5
Which header file contains string handling functions? stdio.h
What is the output? char s[] = "C Programming"; printf("%c", s[2]); C
What does strlen("Hello") return? 4
What is the output? strcat("Hi","There"); HiThere
Which function copies one string into another? strcpy()
Which will cause a runtime error? strcpy(s1,"Hello") for s1[3]="Hi" No error
What is output? char s[]="abc"; printf("%d",sizeof(s)); 3
Which function compares two strings lexicographically? strcmp()
What will strcmp("abc","abd") return? 0
What happens when: char *s="Hello"; s[0]="M"; Mello
What is output? strcat("C"," Language"); C Language
Which function is used to find a substring? strstr()
What is output? printf("%c",*(s+4)) for s="HELLO"; H
char s1[]="Data",s2[]="Data"; if(s1==s2) printf("Equal"); else printf("Not Equal"); Equal
printf("%s","abc"+1); abc
Which correctly declares an array of strings? char arr[3][10];
Which function finds first occurrence of a character? strchr()
char str[]="ABCD"; printf("%c",*(&str[2])); A
Which modifies the original string? strcpy()
strcmp("Hi","Hi"); 1
strlen("abcd"+1); 4
if(strcmp("Code","Code")) printf("Different"); else printf("Same"); Different
What is strcpy()’s return type? int
char s[10]="abc"; s[strlen(s)]="d"; printf("%s",s); abcd
Which reverses a string in C? strrev()
printf("%s",strcpy(str2,str1)); hello
Which string function is not part of standard C? strlen()
char str[]="ababca"; strstr(str,"abca"); abca
Option B Option C Option D Correct Answer BTL Level
An array of characters endA structure A function b Understanding
6 4 Undefined b Remembering
string.h stdlib.h math.h b Remembering
P Space o c Analyzing
5 6 Garbage b Understanding
ThereHi Hi There Error a Applying
strcat() strcmp() strlen() a Remembering
Compile-time error Runtime error Prints Hello c Analyzing
4 5 2 b Understanding
strncmp() strcoll() All of these d Analyzing
1 -1 Error c Understanding
Hello Runtime error Compile-time error c Analyzing
Language C Error a Applying
strchr() strsub() strfind() a Remembering
E L O d Understanding
Not Equal b Analyzing
bc a Error b Analyzing
string arr[3]; char *arr[3]; Both (a) and (c) d Understanding
strrchr() strstr() index() a Remembering
B C D c Understanding
strcat() strrev() All of these d Understanding
-1 0 Garbage c Remembering
3 2 5 b Applying
Same b Understanding
char char * void c Remembering
abc abcd with garbage Undefined c Analyzing
reverse() revstr() flip() a Remembering
error garbage none a Applying
strcmp() strrev() strcpy() c Understanding
ababca Not found ab c Analyzing

You might also like