Computer StudyMCQ Computer ScienceQuiz Computer ScienceUGC NET

C Programming Questions and Answers – Character Class Testing & Conversions

C Programming Questions and Answers – Character Class Testing & Conversions

 

1.Which of the following library function is not case-sensitive?

a) toupper()

b) tolower()

c) isdigit()

d) All of the mentioned

View Answer

Answer:c

2.The following expression can be substituted for.

if (isalpha(c) && isdigit(c))

a) if (isalnum(c))

b) if (isalphanum(c))

c) if (isalphanumeric(c))

d) None of the mentioned

View Answer

Answer:d 

3.Which of the following will return a non-zero value when checked with isspace(c)?

a) blank

b) newline

c) return

d) All of the mentioned

View Answer

Answer:d 

4.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

char i = 9;

if (isdigit(i))

printf(“digit\n”);

else

printf(“not digit\n”);

return 0;

}

a) digit

b) not digit

c) Depends on the compiler

d) None of the mentioned

View Answer

Answer:b

5.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

int i = 9;

if (isdigit(i))

printf(“digit\n”);

else

printf(“not digit\n”);

return 0;

}

a) digit

b) not digit

c) Depends on the compiler

d) None of the mentioned

View Answer

Answer:b

6.What is the output of this C code?

#include <stdio.h>

int main()

{

char i = ‘9’;

if (isdigit(i))

printf(“digit\n”);

else

printf(“not digit\n”);

return 0;

}

a) digit

b) not digit

c) Depends on the compiler

d) None of the mentioned

View Answer

Answer:a 

7.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

if (isspace(‘n’))

printf(“space\n”);

else

printf(“not space\n”);

return 0;

}

a) Compile time error

b) space

c) not space

d) None of the mentioned

View Answer

Answer:b 

8.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

int i = 0;

if (isspace(i))

printf(“space\n”);

else

printf(“not space\n”);

return 0;

}

a) Compile time error

b) space

c) not space

d) None of the mentioned

View Answer

Answer:c  

9.Which is true about isaplpha(c), where c is an int that can be represented as an unsigned

char or EOF.isalpha(c) returns?

a) Non-zero if c is alphabetic

b) 0 if c is not alphabetic

c) Both a & b

d) None of the mentioned

View Answer

Answer:c

10.Which is true about isupper(c), where c is an int that can be represented as an unsigned

char or EOF.isupper(c) returns?

a) Non-zero if c is upper case

b) 0 if c is not upper case

c) Nothing

d) Both a & b

View Answer

Answer:d

11.Which is true about isalnum(c), where c is an int that can be represented as an unsigned

char or EOF.isalnum(c) returns?

a) Non-zero if isalpha(c) or isdigit(c)

b) 0 if not isalpha(c) or not isdigit(c)

c) Both a & b

d) None of the mentioned

View Answer

Answer:c

12.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

char c = ‘t’;

printf(“%d\n”, isspace(c));

}

a) Non-zero number

b) Nothing

c) Error

d) t

View Answer

Answer:a

13.What is the output of this C code?

#include <stdio.h>

#include <ctype.h>

int main()

{

char c = ‘t’;

printf(“is :%c\n”, tolower(‘A’));

}

a) A

b) a

c) Non-zero number

d) Zero

View Answer

Answer:b

14.Which types of input are accepted in toupper(c)?

a) char

b) char *

c) float

d) Both (a) and (b)

View Answer

Answer:a

15.What is the difference in the ASCII value of capital and non-capital of the same letter is?

a) 1

b) 16

c) 32

d) Depends with compiler

View Answer

Answer:c

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button