Font size
Worksheetsstrings
Total questions: 160
Worksheet time: 2hrs 35mins
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array
What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?
%d
%f
%s
%c
What is the output?
int main()
{
char str[]={'B','M','E','\0'};
printf("%s",str);
return 0;
}
BME
BME with garbage value at the end
BME\0
error
What is the output of C program with strings.?
int main()
{
char str1[]="SMART";
char str2[10];
str2 = str1;
printf("%s",str2);
return 0;
}
SMART
SMART followed by 5 spaces
SMART followed by 4 spaces
can not assign one string to another
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: South Africa
South
South Africa
S
Compiler error
How do you accept a Multi Word Input in C Language.?
scanf()
gets()
getc()
finds()
Any function working with String knowns the String has ended when it encounters
null character
Empty space
"\1"
pointer
What is the output of C Program with Strings.?
int main()
{
char ary[]="Discovery Channel";
printf("%s",ary);
return 0;
}
D
Discovery Channel
Discovery
Compiler error
Size of the array need not be specified, when
Initialization is a part of definition
It is a formal parameter
It is a declaration
All of the above
An array Index starts with.?
-1
0
1
2
What is the correct way to mention a big sentence in the next line in C programming?
Use single quotes to enclose the sentence
Add a comma at the end of the sentence
Add a backslash at the end of the sentence
Use double quotes to enclose the sentence
What is the preferred method to mention a sentence in the next line in C programming?
Using parentheses
Using double quotes
Using backslash
Using single quotes
What is the output of the following code snippet:
char s[]="Ruler";
char p[]="Simha";
strcat(p,s);
printf("%s,%s",p,s);
SimhaRuler,Ruler
Simha,Ruler
RulerSimha,Ruler
Ruler,Simha
What is the output of the following code snippet:
char s[]="Syeraa";
char p[]="NarasimhaReddy";
printf("%d",strcmp(p,s));
5
-5
Not Equal
6
What is the output of the following code snippet:
char s[]="Mari-2";
printf("%s",strupr(s));
MARI-2
mari-2
MARI**
Invalid string
What is the output of the following code snippet:
char s[]="Saaho";
printf("%d,%d",strlen(s),sizeof(s));
5,5
6,6
5,6
5,1
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array.
Choose a correct statement about C String.
char ary[]="Hello..!";
Character array, ary is a string.
ary has no Null character at the end
String size is not mentioned
String can not contain special characters.
What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?
%c
%C
%s
%w
What is the output of C Program with Strings.?
int main()
{
char ary[]="Discovery Channel";
printf("%s",ary);
return 0;
}
D
Discovery Channel
Discovery
Compiler error
Which function will you choose to join two words?
strcpy()
strcat()
strncon()
memcon()
Which of the following pointer is Wild
int *p;
int *q=&a;
int *v=NULL;
void *g;
What is the main drawback of pointers
Complexity to mange pointers
Difficult to write program
They are not safe
What is the output of the following Code:
#include <stdio.h>
int main()
{
int *p;
int a=10;
p=&a;
*p=34;
printf("%d,%d",a,*p);
return 0;
}
34,34
10,10
10,34
34,10
What is the output of the following code:
#include <stdio.h>
int main()
{
void *z;
float s=1.2;
z=&s;
printf("%f",*z);
return 0;
}
Compile time error
1.20000
1.2
Run time error
What is the output of the following code:
#include <stdio.h>
int main()
{
int *p;
int a=20;
p=&a;
int **q;
**q=100;
q=&p;
*p=50;
printf("%d,%d,%d",**q,a,*p);
return 0;
}
50,50,50
20,20,50
100,50,20
100,20,50
What is the output of the following code snippet:
int a=45,b=67;
int *s,*q;
s=&a;q=&b;
printf("%d",s+q);
Compile time error
112
Garbage value
0
Which of the following operators are not used with pointers
*
/
%
-
What is the output of the following code:
int a[]={1,2,33,4,4,6}
int *p;
p=a;
*(p+2)=25;
printf("%d,%d",*(p+2),2[a]);
25,25
25,4
25, garbage value
Compile time error
Which of the following pointers leads to memory leaks
Wild Pointers
Dangling Pointers
NULL Pointers
Generic Pionters
Which of the following is related to pointer to an array concept in C
int a[]={1,2,2,22};
int *p;
p=a;
int (*p)[3];
int a[]={1,2,3};
p=&a;
int *p[3];
int a[]={1,2,2};
p=a;
int **a[];
What is the result of following code snippet: (for 16 bit compiler)
char *s;
long double *z;
printf("%d,%d",sizeof(s),sizeof(z));
2,2
4,4
1,10
Undefined
What is the output of the following code:
char *p="Welcome to GEC";
printf("%s",p+10);
GEC
to GEC
It prints Memory address
Invalid syntax of printf
What is the output of the following code:
char *s="welcome to IT";
printf("%d",1[s]-s[6]);
0
e
-5
2
What is the output of the following code snippet:
char s[]="Ruler";
char p[]="Simha";
strcat(p,s);
printf("%s,%s",p,s);
SimhaRuler,Ruler
Simha,Ruler
RulerSimha,Ruler
Ruler,Simha
What is the output of the following code snippet:
char s[]="Syeraa";
char p[]="NarasimhaReddy";
printf("%d",strcmp(p,s));
5
-5
Not Equal
6
In C language Strings are _______________
Mutable
Immutable
Both Mutable and Immutable
No Mutable and immutable concept in C
What is the output of the following code snippet:
char s[]="Mari-2";
printf("%s",strupr(s));
MARI-2
mari-2
MARI**
Invalid string
What is the output of the following code snippet:
char s[]="Ismart Shankar";
printf("%s",3+s+4);
Shankar
t Shankar
Error
art Shankar
What is the output of the following code snippet:
char s[]="Saaho";
printf("%d,%d",strlen(s),sizeof(s));
5,5
6,6
5,6
5,1
What is the output of the following code snippet:
char s[5]="GECIT";
printf("%s",strrev(s));
TICEG
Compile time Error
GECIT
gecit
What is the answer for the following code:
int a=20;
printf("%p",a);
0014
14
32
20
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array.
Choose a correct statement about C String.
char ary[]="Hello..!";
Character array, ary is a string.
ary has no Null character at the end
String size is not mentioned
String can not contain special characters.
What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?
%c
%C
%s
%w
What is the output of C Program with Strings.?
int main()
{
char ary[]="Discovery Channel";
printf("%s",ary);
return 0;
}
D
Discovery Channel
Discovery
Compiler error
What is the output of C Program with Strings.?
int main()
{
char str[]={'g','l','o','b','e'};
printf("%s",str);
return 0;
}
g
globe
globe\0
None of the above
What is the output of C Program with arrays.?
int main()
{
char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;
}
C
CAT
CAT\0
Compiler error
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
KL
KLMN
Compiler error
None of the above
Which function will you choose to join two words?
strcpy()
strcat()
strncon()
memcon()
The ______ function appends not more than n characters.
strcat()
strcon()
strncat()
memcat()
What will strcmp() function do?
compares the first n characters of the object
compares the string
undefined function
copies the string
What does the strcmp() function do?
Compares two strings character by character
Copies one string to another
Concatenates two strings
Returns the length of a string
What is the return value of strcmp() when the strings are equal?
0
>0
<0
1
What does the strcat() function do?
Copies one string to another
Compares two strings
Concatenates two strings
Returns the length of a string
What should be considered when using strcat()?
The destination string must be large enough
The source string must be empty
The destination string must be empty
The source string must be larger than the destination
How can you copy a string in C?
Using the strcpy function
Using the strcat function
Using the strlen function
Using the strcmp function
What is a string in C programming?
A sequence of integers
A sequence of characters terminated with a null character
A data type for floating-point numbers
A single character
How do you declare a string in C?
char s = 'hello';
char s[5];
string s[5];
char s(5);
What happens when you try to assign a string to an already declared array?
It appends the string to the array
It overwrites the array
It causes a compilation error
It works without issues
Which function is used to read a string from the user?
fgets()
gets()
scanf()
printf()
What is the output of the following code: printf("%s", name); where name is declared as char name[20]; and filled using scanf()?
It prints the entire input
It prints only the first word
It prints nothing
It causes a runtime error
Which function is removed from the C standard due to security issues?
puts()
strcpy()
fgets()
gets()
What does the strlen() function do?
Compares two strings
Calculates the length of a string
Copies a string
Concatenates two strings
What is the purpose of the strcat() function?
To compare two strings
To copy one string to another
To concatenate two strings
To find the length of a string
What does the strcmp() function return when two strings are equal?
1
A positive integer
0
-1
Which header file must be included to use string handling functions?
stdio.h
stdlib.h
string.h
conio.h
What is the correct prototype for the strcpy() function?
char strcpy(char* dest, const char* src);
void strcpy(char* dest, char* src);
char* strcpy(char* dest, const char* src);
int strcpy(char* dest, const char* src);
What is the output of the following code: char str1[] = "abc", str2[] = "abc"; printf("%d", strcmp(str1, str2));?
0
1
Undefined behavior
-1
Which function is used to display a string?
gets()
puts()
printf()
scanf()
What will happen if you try to read a string longer than the declared size using fgets()?
It will ignore the input
It will read up to the size limit
It will cause a buffer overflow
It will read the entire string
What does the strlwr() function do?
Calculates the length of a string
Reverses a string
Converts a string to lowercase
Converts a string to uppercase
What is right way to Initialize array?
int num[6] = { 2, 4, 12, 5, 45, 5 };
int n{} = { 2, 4, 12, 5, 45, 5 };
int n{6} = { 2, 4, 12 };
int n(6) = { 2, 4, 12, 5, 45, 5 };
An array elements are always stored in ________ memory locations.
sequential
Random
Sequential and Random
None of the above
what will be printed after Execution of the following program
void main()
{
int a[5]={11,13,56,20,5};
printf("%d",a[2]);
}
garbage value
13
56
20
if two strings are identical then function strcmp() returns
0
-1
true
none of these
what will be the output of the program?
#include <stdio.h>
#include<string .h>
void main()
{
char str1[20]="Hello",str2="world";
strcat(str1,str2);
puts(str1);
return 0;
}
Hello
world
Helloworld
none of the above
8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
arr[6]
arr[7]
arr{6}
arr{7}
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array
An array Index starts with.?
-1
0
1
2
What is the minimum and maximum Indexes of this below array.?
int main()
{
int ary[9];
return 0;
}
-1, 8
0, 8
1,9
None of the above
What is the output of this program
#include <stdio.h>
int main()
{ int a[2][] = { {1,1,1},{2,2,2}};
printf("%d", a[1][1]);
}
1
Error
2
0
Array can be considered as set of elements stored in consecutive memory locations but having __________.
Same data type
Different data type
Same scope
None of these
What is the proper declaration for an array that has 2 rows and 3 columns?
type arr[2][2];
arr[2][3] type;
type arr[2][3];
type arr[4][3];
How can I store the value 10 into the second row, first column of my array that I have declared as int numbers[10][10]?
int numbers[1][2] = 10;
numbers[1][2] = 10;
numbers[2][3] = 10;
numbers[1][0] = 10
1 2 3 4 5 5
1 2 3 4 5 0
1 2 3 4 5 Garbage value
Error
if two strings are identical then function strcmp() returns
0
-1
true
none of these
what will be the output of the program?
#include <stdio.h>
#include<string .h>
void main()
{
char str1[20]="Hello",str2="world";
strcat(str1,str2);
puts(str1);
return 0;
}
Hello
world
Helloworld
none of the above
str1="6/4";
printf("str1");
6/4
str1
None
Which of the following function is more appropriate for reading in a multi-word string?
scanf()
printf()
puts()
gets()
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: South Africa
South
South Africa
S
Compiler error
What is the output of C program with strings.?
int main()
{
char str1[]="SMART";
char str2[10];
str2 = str1;
printf("%s",str2);
return 0;
}
SMART
SMART followed by 5 spaces
SMART followed by 4 spaces
can not assign one string to another
What will the output of the following program?
#include <stdio.h>
int main()
{
char str1[] = "College";
char str2[] = "University";
strcpy(str1, str2);
printf("%s", str1);
}
College
University
College University
University College
What is right way to Initialize array?
int num[6] = { 2, 4, 12, 5, 45, 5 };
int n{} = { 2, 4, 12, 5, 45, 5 };
int n{6} = { 2, 4, 12 };
int n(6) = { 2, 4, 12, 5, 45, 5 };
An array elements are always stored in ________ memory locations.
sequential
Random
Sequential and Random
None of the above
what will be printed after Execution of the following program
void main()
{
int a[5]={11,13,56,20,5};
printf("%d",a[2]);
}
garbage value
13
56
20
8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
arr[6]
arr[7]
arr{6}
arr{7}
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array
An array Index starts with.?
-1
0
1
2
What is the minimum and maximum Indexes of this below array.?
int main()
{
int ary[9];
return 0;
}
-1, 8
0, 8
1,9
None of the above
What is the output of C Program.?
int main()
{
char grade[] = {'A','B','C'}; printf("GRADE=%c, ", *grade); printf("GRADE=%d", grade);
}
GRADE=some address of array, GRADE=A
GRADE=A, GRADE=some address of array
GRADE=A, GRADE=A
Compiler error
What is the output of C program.?
int main() {
char grade[] = {'A','B','C'}; printf("GRADE=%d, ", *grade); printf("GRADE=%d", grade[0]);
}
A A
65 A
65 65
None
What is the output of C program.?
int main()
{
float marks[3] = {90.5, 92.5, 96.5};
int a=0;
while(a<3)
{
printf("%.2f,", marks[a]); a++;
}
}
90.5 92.5 96.5
90.50 92.50 96.50
0.00 0.00 0.00
Compiler error
What is the output of C Program.?
int main() {
int a[3] = {10,12,14};
a[1]=20;
int i=0;
while(i<3)
{ printf("%d ", a[i]);
i++; }
}
20 12 14
10 20 14
10 12 20
Error
What is the output of C program with arrays.?
int main() {
int a[3] = {20,30,40};
int b[3];
b=a;
printf("%d", b[0]);
}
20
30
address of 0th element.
Compiler error
Which is not a built in function
string()
strlen()
strcat()
strcmp()
String is an array of characters with …….. character as the last element of array.
Null
Empty
0
1
What is the format specifier used to print or read a character in an array in Printf or Scanf function?
%C
%f
%w
%c
String is initialized with datatype
float
char
int
double
What is the output of this program?
#include <stdio.h>
int main()
{
char str[] = "hello, world";
printf("%d", strlen(str));
}
Compilation error
10
13
12
What is the output of
#include <stdio.h>
int main()
{
char str[8]="IncludeHelp";
printf("%s",str);
return 0;
}
IncludeHelp
IncludeH
Error
No Output
What is the output of this
#include <stdio.h>
#include <string.h>
int main()
{
char s1[10] = "Hello";
char s2[10] = "World";
strncat(s1,s2, 3);
printf("Concatenation using strncat: %s", s1);
return 0;
}
Concatenation using strncat: Hel
Concatenation using strncat: HelloWorld
Concatenation using strncat: HelloWor
None of the above
What is the output of the below program
#include <stdio.h>
#include <string.h>
int main()
{
char str1[] = "abcd", str2[] = "abcd";
int result;
result = strcmp(str1, str2);
printf("strcmp(str1, str2) = %d\n", result);
return 0;
}
0
1
Invalid
None of the above
What will be the output of the below program
#include <stdio.h>
int main()
{
int a[5]={5,1,15,20,25};
int i,j,m;
i=++a[1];
j=a[1]++;
m=a[i++];
printf("%d,%d,%d",i,j,m);
}
3,2,15
2,3,20
2,1,15
1,2,5
What will be the output of the following program?
#include <stdio.h>
#include <string.h>
void main()
{
char str1[] = "Salem";
char str2[] = "Bangalore";
printf("%d" ,(strcmp(str1, str2)));
}
0
-1
1
Compile time Error
What will be the output of the following program?
#include <stdio.h>
#include <string.h>
void main()
{
char str1[] = "Australia";
char str2[] = "India";
printf("%d" ,(strcmp(str1, str2)));
}
0
-1
1
run time error
What will the output of the following program?
#include <stdio.h>
#include <string.h>
void main()
{
char str1[] = "College";
char str2[] = "University";
strcpy(str1, str2);
printf("%s", str1);
}
College
University
College University
University College
Which of the following is true about strcat function?
Strcat() function adds null character
Only if there is space
Always
Depends on the standard
Depends on the compiler
What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
void main()
{
char str1[] = "BioMedical ";
char str2[] = "Engineering";
strcat(str1, str2);
printf("%s ", str1);
}
BioMedical
BioMedical Engineering
BioEngineering
Engineering
