wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

strings

Total questions: 160

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array

2.

What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?

a)

%d

b)

%f

c)

%s

d)

%c

3.

What is the output?

int main()

{

char str[]={'B','M','E','\0'};

printf("%s",str);

return 0;

}

a)

BME

b)

BME with garbage value at the end

c)

BME\0

d)

error

4.

What is the output of C program with strings.?

int main()

{

char str1[]="SMART";

char str2[10];

str2 = str1;

printf("%s",str2);

return 0;

}

a)

SMART

b)

SMART followed by 5 spaces

c)

SMART followed by 4 spaces

d)

can not assign one string to another

5.

int main()

{

char str[25];

scanf("%s", str);

printf("%s",str);

return 0;

}

//input: South Africa

a)

South

b)

South Africa

c)

S

d)

Compiler error

6.

How do you accept a Multi Word Input in C Language.?

a)

scanf()

b)

gets()

c)

getc()

d)

finds()

7.

Any function working with String knowns the String has ended when it encounters

a)

null character

b)

Empty space

c)

"\1"

d)

pointer

8.

What is the output of C Program with Strings.?


int main()

{

char ary[]="Discovery Channel";

printf("%s",ary);

return 0;

}

a)

D

b)

Discovery Channel

c)

Discovery

d)

Compiler error

9.

Size of the array need not be specified, when

a)

Initialization is a part of definition

b)

It is a formal parameter

c)

It is a declaration

d)

All of the above

10.

An array Index starts with.?

a)

-1

b)

0

c)

1

d)

2

11.

What is the correct way to mention a big sentence in the next line in C programming?

a)

Use single quotes to enclose the sentence

b)

Add a comma at the end of the sentence

c)

Add a backslash at the end of the sentence

d)

Use double quotes to enclose the sentence

12.

What is the preferred method to mention a sentence in the next line in C programming?

a)

Using parentheses

b)

Using double quotes

c)

Using backslash

d)

Using single quotes

13.

What is the output of the following code snippet:


char s[]="Ruler";

char p[]="Simha";

strcat(p,s);

printf("%s,%s",p,s);

a)

SimhaRuler,Ruler

b)

Simha,Ruler

c)

RulerSimha,Ruler

d)

Ruler,Simha

14.

What is the output of the following code snippet:


char s[]="Syeraa";

char p[]="NarasimhaReddy";

printf("%d",strcmp(p,s));

a)

5

b)

-5

c)

Not Equal

d)

6

15.

What is the output of the following code snippet:


char s[]="Mari-2";

printf("%s",strupr(s));

a)

MARI-2

b)

mari-2

c)

MARI**

d)

Invalid string

16.

What is the output of the following code snippet:


char s[]="Saaho";

printf("%d,%d",strlen(s),sizeof(s));

a)

5,5

b)

6,6

c)

5,6

d)

5,1

17.
What value is at index 1 in this array?  String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
a)
Mack
b)
Dennis
c)
Dee
d)
Charlie
18.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array.

19.

Choose a correct statement about C String.


char ary[]="Hello..!";

a)

Character array, ary is a string.

b)

ary has no Null character at the end

c)

String size is not mentioned

d)

String can not contain special characters.

20.

What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?

a)

%c

b)

%C

c)

%s

d)

%w

21.

What is the output of C Program with Strings.?


int main()

{

char ary[]="Discovery Channel";

printf("%s",ary);

return 0;

}

a)

D

b)

Discovery Channel

c)

Discovery

d)

Compiler error

22.

Which function will you choose to join two words?

a)

strcpy()

b)

strcat()

c)

strncon()

d)

memcon()

23.

Which of the following pointer is Wild

a)

int *p;

b)

int *q=&a;

c)

int *v=NULL;

d)

void *g;

24.

What is the main drawback of pointers

a)

Complexity to mange pointers

b)

Difficult to write program

c)

They are not safe

25.

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;

}

a)

34,34

b)

10,10

c)

10,34

d)

34,10

26.

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;

}

a)

Compile time error

b)

1.20000

c)

1.2

d)

Run time error

27.

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;

}

a)

50,50,50

b)

20,20,50

c)

100,50,20

d)

100,20,50

28.

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);

a)

Compile time error

b)

112

c)

Garbage value

d)

0

29.

Which of the following operators are not used with pointers

a)

*

b)

/

c)

%

d)

-

30.

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]);

a)

25,25

b)

25,4

c)

25, garbage value

d)

Compile time error

31.

Which of the following pointers leads to memory leaks

a)

Wild Pointers

b)

Dangling Pointers

c)

NULL Pointers

d)

Generic Pionters

32.

Which of the following is related to pointer to an array concept in C

a)

int a[]={1,2,2,22};

int *p;

p=a;

b)

int (*p)[3];

int a[]={1,2,3};

p=&a;

c)

int *p[3];

int a[]={1,2,2};

p=a;

d)

int **a[];

33.

What is the result of following code snippet: (for 16 bit compiler)


char *s;

long double *z;

printf("%d,%d",sizeof(s),sizeof(z));

a)

2,2

b)

4,4

c)

1,10

d)

Undefined

34.

What is the output of the following code:


char *p="Welcome to GEC";

printf("%s",p+10);

a)

GEC

b)

to GEC

c)

It prints Memory address

d)

Invalid syntax of printf

35.

What is the output of the following code:


char *s="welcome to IT";

printf("%d",1[s]-s[6]);

a)

0

b)

e

c)

-5

d)

2

36.

What is the output of the following code snippet:


char s[]="Ruler";

char p[]="Simha";

strcat(p,s);

printf("%s,%s",p,s);

a)

SimhaRuler,Ruler

b)

Simha,Ruler

c)

RulerSimha,Ruler

d)

Ruler,Simha

37.

What is the output of the following code snippet:


char s[]="Syeraa";

char p[]="NarasimhaReddy";

printf("%d",strcmp(p,s));

a)

5

b)

-5

c)

Not Equal

d)

6

38.

In C language Strings are _______________

a)

Mutable

b)

Immutable

c)

Both Mutable and Immutable

d)

No Mutable and immutable concept in C

39.

What is the output of the following code snippet:


char s[]="Mari-2";

printf("%s",strupr(s));

a)

MARI-2

b)

mari-2

c)

MARI**

d)

Invalid string

40.

What is the output of the following code snippet:


char s[]="Ismart Shankar";

printf("%s",3+s+4);

a)

Shankar

b)

t Shankar

c)

Error

d)

art Shankar

41.

What is the output of the following code snippet:


char s[]="Saaho";

printf("%d,%d",strlen(s),sizeof(s));

a)

5,5

b)

6,6

c)

5,6

d)

5,1

42.

What is the output of the following code snippet:


char s[5]="GECIT";

printf("%s",strrev(s));

a)

TICEG

b)

Compile time Error

c)

GECIT

d)

gecit

43.

What is the answer for the following code:


int a=20;

printf("%p",a);

a)

0014

b)

14

c)

32

d)

20

44.
A string in C is
a)
D Array of Character
b)
D Array of Character
c)
Any of i & ii
d)
None of the above
45.
A String constant in C terminated by
a)
\O'
b)
\\O'
c)
"
d)
" "
46.
Any function working with String knowns the String has ended when it encounters
a)
null character
b)
Empty space
c)
"\1"
d)
pointer
47.
Which of the following is format specification for printing String in printf()?
a)
%d
b)
%c
c)
%f
d)
%s
48.
To receive multi-word string from keyboard which of the function is more appropriate?
a)
Scanf
b)
gets()
c)
both
d)
None of the above
49.
puts() can display only one string at a time.
a)
true
b)
false
c)
NA
d)
NA
50.
Which string method helps find length of string?
a)
stringLength()
b)
strlen
c)
strdup
d)
both i & ii
51.
Which of the following function duplicates a string?
a)
strnset
b)
strstr
c)
strdup
d)
stricmp
52.
What is a String in C Language.?
a)
String is a new Data Type in C
b)
String is an array of Characters with null character as the last element of array.
c)
String is an array of Characters with null character as the first element of array
d)
String is an array of Integers with 0 as the last element of array.
53.
Choose a correct statement about C String. char ary[]="Hello..!";
a)
Character array, ary is a string.
b)
ary has no Null character at the end
c)
String size is not mentioned
d)
String can not contain special characters.
54.
Which among the following is Copying function?
a)
memcpy()
b)
strcopy()
c)
memcopy()
d)
strxcpy()
55.
Which function will you choose to join two words?
a)
strcpy()
b)
strcat()
c)
strncon()
d)
memcon()
56.
The ______ function appends not more than n characters.
a)
strcat()
b)
strcon()
c)
strncat()
d)
memcat()
57.
What will strcmp() function do?
a)
compares the first n characters of the object
b)
compares the string
c)
undefined function
d)
copies the string
58.
Which of the following is the variable type defined in header string. h?
a)
sizet
b)
size
c)
size_t
d)
size-t
59.
<br />If the two strings are identical, then strcmp() function returns
a)
-1
b)
1
c)
0
d)
Yes
60.
Choose a correct C Statement about Strings.
a)
PRINTF is capable of printing a multi word string.
b)
PUTS is capable of printing a multi word string.
c)
GETS is capable of accepting a multi word string from console or command prompt
d)
All the above
61.
How do you accept a Multi Word Input in C Language.?
a)
SCANF
b)
GETS
c)
GETC
d)
FINDS
62.
What is the output of C Program with strings.?<br />int main()<br />{<br /> char str[2];<br /> int i=0;<br /> scanf("%s", str);<br /> while(str[i] != '\0')<br /> {<br /> printf("%c", str[i]);<br /> i++;<br /> }<br /> return 0;<br />}<br />//Input: KLMN
a)
KL
b)
KLMN
c)
Compiler error
d)
None of the above
63.
What is the output of C program with strings.?<br />int main()<br />{<br /> char str[2];<br /> scanf("%s", str);<br /> printf("%s",str);<br /> return 0;<br />}<br />//Input: South
a)
So
b)
south
c)
Compiler error
d)
None of the above
64.
What is the output of C Program with arrays.?<br />int main()<br />{<br /> char str[25];<br /> scanf("%s", str);<br /> printf("%s",str);<br /> return 0;<br />}<br />//input: South Africa
a)
South
b)
South Africa
c)
S
d)
Compiler error
65.
What is the output of C program with strings.?<br />int main()<br />{<br /> char str1[]="JOHN";<br /> char str2[20];<br /> str2= str1;<br /> printf("%s",str2);<br /> return 0;<br />}
a)
JOHN
b)
J
c)
JOHN\0
d)
Compiler error
66.
Compiler error
a)
32 characters
b)
64 characters
c)
256 characters
d)
None of the above
67.
What is the output of C Program with arrays.?
a)
C
b)
CAT
c)
CAT\0
d)
Compiler error
68.
How do you convert this char array to string.?<br />char str[]={'g','l','o','b','y'};
a)
str[5] = 0;
b)
str[5] = '\0'
c)
str[]={'g','l','o','b','y','\0'};
d)
All the above
69.
What is the output of C Program with Strings.? int main()<br />{<br /> char str[]={'g','l','o','b','y','\0'};<br /> printf("%s",str);<br /> return 0;<br />}
a)
g
b)
globe
c)
globe\0
d)
Compiler error
70.
What is the output of C Program with Strings.? int main()<br />{<br /> char str[]={'g','l','o','b','e'};<br /> printf("%s",str);<br /> return 0;<br />}
a)
g
b)
globe
c)
globe\0
d)
None of the above
71.
Which of the following function is used to find the first occurrence of a given string in another string?
a)
strchr()
b)
strrchr()
c)
strstr()
d)
strnset()
72.
The library function used to find the last occurrence of a character in a string is
a)
strnstr()
b)
laststr()
c)
strrchr()
d)
strstr()
73.
What is the output of C Program with Strings.? int main()<br />{<br /> char ary[]="Discovery Channel";<br /> printf("%s",ary);<br /> return 0;<br />}
a)
D
b)
Discovery Channel
c)
Discovery
d)
Compiler error
74.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array.

75.

Choose a correct statement about C String.


char ary[]="Hello..!";

a)

Character array, ary is a string.

b)

ary has no Null character at the end

c)

String size is not mentioned

d)

String can not contain special characters.

76.

What is the Format specifier used to print a String or Character array in C Printf or Scanf function.?

a)

%c

b)

%C

c)

%s

d)

%w

77.

What is the output of C Program with Strings.?


int main()

{

char ary[]="Discovery Channel";

printf("%s",ary);

return 0;

}

a)

D

b)

Discovery Channel

c)

Discovery

d)

Compiler error

78.

What is the output of C Program with Strings.?


int main()

{

char str[]={'g','l','o','b','e'};

printf("%s",str);

return 0;

}

a)

g

b)

globe

c)

globe\0

d)

None of the above

79.

What is the output of C Program with arrays.?


int main()

{

char str[]={"C","A","T","\0"};

printf("%s",str);

return 0;

}

a)

C

b)

CAT

c)

CAT\0

d)

Compiler error

80.

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

a)

KL

b)

KLMN

c)

Compiler error

d)

None of the above

81.

Which function will you choose to join two words?

a)

strcpy()

b)

strcat()

c)

strncon()

d)

memcon()

82.

The ______ function appends not more than n characters.

a)

strcat()

b)

strcon()

c)

strncat()

d)

memcat()

83.

What will strcmp() function do?

a)

compares the first n characters of the object

b)

compares the string

c)

undefined function

d)

copies the string

84.

What does the strcmp() function do?

a)

Compares two strings character by character

b)

Copies one string to another

c)

Concatenates two strings

d)

Returns the length of a string

85.

What is the return value of strcmp() when the strings are equal?

a)

0

b)

>0

c)

<0

d)

1

86.

What does the strcat() function do?

a)

Copies one string to another

b)

Compares two strings

c)

Concatenates two strings

d)

Returns the length of a string

87.

What should be considered when using strcat()?

a)

The destination string must be large enough

b)

The source string must be empty

c)

The destination string must be empty

d)

The source string must be larger than the destination

88.

How can you copy a string in C?

a)

Using the strcpy function

b)

Using the strcat function

c)

Using the strlen function

d)

Using the strcmp function

89.

What is a string in C programming?

a)

A sequence of integers

b)

A sequence of characters terminated with a null character

c)

A data type for floating-point numbers

d)

A single character

90.

How do you declare a string in C?

a)

char s = 'hello';

b)

char s[5];

c)

string s[5];

d)

char s(5);

91.

What happens when you try to assign a string to an already declared array?

a)

It appends the string to the array

b)

It overwrites the array

c)

It causes a compilation error

d)

It works without issues

92.

Which function is used to read a string from the user?

a)

fgets()

b)

gets()

c)

scanf()

d)

printf()

93.

What is the output of the following code: printf("%s", name); where name is declared as char name[20]; and filled using scanf()?

a)

It prints the entire input

b)

It prints only the first word

c)

It prints nothing

d)

It causes a runtime error

94.

Which function is removed from the C standard due to security issues?

a)

puts()

b)

strcpy()

c)

fgets()

d)

gets()

95.

What does the strlen() function do?

a)

Compares two strings

b)

Calculates the length of a string

c)

Copies a string

d)

Concatenates two strings

96.

What is the purpose of the strcat() function?

a)

To compare two strings

b)

To copy one string to another

c)

To concatenate two strings

d)

To find the length of a string

97.

What does the strcmp() function return when two strings are equal?

a)

1

b)

A positive integer

c)

0

d)

-1

98.

Which header file must be included to use string handling functions?

a)

stdio.h

b)

stdlib.h

c)

string.h

d)

conio.h

99.

What is the correct prototype for the strcpy() function?

a)

char strcpy(char* dest, const char* src);

b)

void strcpy(char* dest, char* src);

c)

char* strcpy(char* dest, const char* src);

d)

int strcpy(char* dest, const char* src);

100.

What is the output of the following code: char str1[] = "abc", str2[] = "abc"; printf("%d", strcmp(str1, str2));?

a)

0

b)

1

c)

Undefined behavior

d)

-1

101.

Which function is used to display a string?

a)

gets()

b)

puts()

c)

printf()

d)

scanf()

102.

What will happen if you try to read a string longer than the declared size using fgets()?

a)

It will ignore the input

b)

It will read up to the size limit

c)

It will cause a buffer overflow

d)

It will read the entire string

103.

What does the strlwr() function do?

a)

Calculates the length of a string

b)

Reverses a string

c)

Converts a string to lowercase

d)

Converts a string to uppercase

104.
int a[10]; array can store maximum _____number of elements.
a)
10
b)
20
c)
9
d)
1
105.
In a string the last position is reserved for _____
a)
NULL characater
b)
row size
c)
column size
d)
row and column size
106.
Which format specification is used in scanf() to read a string?
a)
%d
b)
%ld
c)
%f
d)
%s
107.
Which amongst the header file contains gets ( ) function in C language.
a)
math.h
b)
string.h
c)
stdio.h
d)
process.h
108.
The function strcat ( ) has _______ number of parameters
a)
2
b)
1
c)
3
d)
0
109.
When 2 strings are equal strcmp() function returns _____.
a)
0
b)
1
c)
2
d)
-2
110.
The function strcpy(s2,s1) copies
a)
String s1 to s2
b)
String s2 to s1
c)
Does not copy
d)
error
111.
Which string function is used to determine the length of the string?
a)
strrev()
b)
strlen()
c)
strcmp()
d)
strcat()
112.
A function may be called __________from any other functions.
a)
only once
b)
only twice
c)
more than once
d)
only three times
113.
By default ________ is the return type of a C function.
a)
char
b)
float
c)
int
d)
double
114.

What is right way to Initialize array?

a)

int num[6] = { 2, 4, 12, 5, 45, 5 };

b)

int n{} = { 2, 4, 12, 5, 45, 5 };

c)

int n{6} = { 2, 4, 12 };

d)

int n(6) = { 2, 4, 12, 5, 45, 5 };

115.

An array elements are always stored in ________ memory locations.

a)

sequential

b)

Random

c)

Sequential and Random

d)

None of the above

116.

what will be printed after Execution of the following program

void main()

{

int a[5]={11,13,56,20,5};

printf("%d",a[2]);

}

a)

garbage value

b)

13

c)

56

d)

20

117.

if two strings are identical then function strcmp() returns

a)

0

b)

-1

c)

true

d)

none of these

118.

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;

}

a)

Hello

b)

world

c)

Helloworld

d)

none of the above

119.

8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

a)

arr[6]

b)

arr[7]

c)

arr{6}

d)

arr{7}

120.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array

121.

An array Index starts with.?

a)

-1

b)

0

c)

1

d)

2

122.

What is the minimum and maximum Indexes of this below array.?

int main()

{

int ary[9];

return 0;

}

a)

-1, 8

b)

0, 8

c)

1,9

d)

None of the above

123.

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]);

}

a)

1

b)

Error

c)

2

d)

0

124.

 

Array can be considered as set of elements stored in consecutive memory locations but having __________.

a)

Same data type

b)

Different data type

c)

Same scope

d)

None of these

125.

What is the proper declaration for an array that has 2 rows and 3 columns?

a)

type arr[2][2];

b)

arr[2][3] type;

c)

type arr[2][3];

d)

type arr[4][3];

126.

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]?

a)

int numbers[1][2] = 10;

b)

numbers[1][2] = 10;

c)

numbers[2][3] = 10;

d)

numbers[1][0] = 10

127.
a)

1 2 3 4 5 5

b)

1 2 3 4 5 0

c)

1 2 3 4 5 Garbage value

d)

Error

128.

if two strings are identical then function strcmp() returns

a)

0

b)

-1

c)

true

d)

none of these

129.

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;

}

a)

Hello

b)

world

c)

Helloworld

d)

none of the above

130.

str1="6/4";

printf("str1");

a)

6/4

b)

str1

c)

None

131.

Which of the following function is more appropriate for reading in a multi-word string?

a)

scanf()

b)

printf()

c)

puts()

d)

gets()

132.

int main()

{

char str[25];

scanf("%s", str);

printf("%s",str);

return 0;

}

//input: South Africa

a)

South

b)

South Africa

c)

S

d)

Compiler error

133.

What is the output of C program with strings.?

int main()

{

char str1[]="SMART";

char str2[10];

str2 = str1;

printf("%s",str2);

return 0;

}

a)

SMART

b)

SMART followed by 5 spaces

c)

SMART followed by 4 spaces

d)

can not assign one string to another

134.

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);

}

a)

College

b)

University

c)

College University

d)

University College

135.

What is right way to Initialize array?

a)

int num[6] = { 2, 4, 12, 5, 45, 5 };

b)

int n{} = { 2, 4, 12, 5, 45, 5 };

c)

int n{6} = { 2, 4, 12 };

d)

int n(6) = { 2, 4, 12, 5, 45, 5 };

136.

An array elements are always stored in ________ memory locations.

a)

sequential

b)

Random

c)

Sequential and Random

d)

None of the above

137.

what will be printed after Execution of the following program

void main()

{

int a[5]={11,13,56,20,5};

printf("%d",a[2]);

}

a)

garbage value

b)

13

c)

56

d)

20

138.

8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

a)

arr[6]

b)

arr[7]

c)

arr{6}

d)

arr{7}

139.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array

140.

An array Index starts with.?

a)

-1

b)

0

c)

1

d)

2

141.

What is the minimum and maximum Indexes of this below array.?

int main()

{

int ary[9];

return 0;

}

a)

-1, 8

b)

0, 8

c)

1,9

d)

None of the above

142.

What is the output of C Program.?

int main()

{

char grade[] = {'A','B','C'}; printf("GRADE=%c, ", *grade); printf("GRADE=%d", grade);

}

a)

GRADE=some address of array, GRADE=A

b)

GRADE=A, GRADE=some address of array

c)

GRADE=A, GRADE=A

d)

Compiler error

143.

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 A

b)

65 A

c)

65 65

d)

None

144.

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++;

}

}

a)

90.5 92.5 96.5

b)

90.50 92.50 96.50

c)

0.00 0.00 0.00

d)

Compiler error

145.

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++; }

}

a)

20 12 14

b)

10 20 14

c)

10 12 20

d)

Error

146.

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]);

}

a)

20

b)

30

c)

address of 0th element.

d)

Compiler error

147.

Which is not a built in function

a)

string()

b)

strlen()

c)

strcat()

d)

strcmp()

148.

String is an array of characters with …….. character as the last element of array.

a)

Null

b)

Empty

c)

0

d)

1

149.

What is the format specifier used to print or read a character in an array in Printf or Scanf function?

a)

%C

b)

%f

c)

%w

d)

%c

150.

String is initialized with datatype

a)

float

b)

char

c)

int

d)

double

151.

What is the output of this program?

#include <stdio.h>

int main()

{

        char str[] = "hello, world";

        printf("%d", strlen(str));

        }

a)

Compilation error

b)

10

c)

13

d)

12

152.

What is the output of

#include <stdio.h>

int main()

{

    char str[8]="IncludeHelp";

    printf("%s",str);

    return 0;

}

a)

IncludeHelp

b)

IncludeH

c)

Error

d)

No Output

153.

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;

}

a)

Concatenation using strncat: Hel

b)

Concatenation using strncat: HelloWorld

c)

Concatenation using strncat: HelloWor

d)

None of the above

154.

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;

}

a)

0

b)

1

c)

Invalid

d)

None of the above

155.

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);

}

a)

3,2,15

b)

2,3,20

c)

2,1,15

d)

1,2,5

156.

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)));


}

a)

0

b)

-1

c)

1

d)

Compile time Error

157.

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)));


}

a)

0

b)

-1

c)

1

d)

run time error

158.

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);

}

a)

College

b)

University

c)

College University

d)

University College

159.

Which of the following is true about strcat function?

Strcat() function adds null character

a)

Only if there is space

b)

Always

c)

Depends on the standard

d)

Depends on the compiler

160.

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);

}

a)

BioMedical

b)

BioMedical Engineering

c)

BioEngineering

d)

Engineering