C Strings Questions and Answers
Practice ModeShowing 10 of 26 questions
Q11
char *a="23422"; sozeof (a), strlen(a));
From the above, what is the output of the printf function ?
Answer: Option D
Q12
char name [ ] = 'MIT'
printf ("%s is deprtment %s %d of %s/n', &name [1], "no", ('A' 'a')/", name);
From the above, what is the output of the printf statement ?
Answer: Option C
Q13
char *p;
char name [25] = "MIT-IT";
strcpy (p,name);
printf("%s",p);
What will be the output?
Answer: Option A
Q14
char name [10];
scanf ("%s", name);
if (strcmp (name, "chennai") = = 0
{
char a[10] = "600028";
printf ("Mandaveli has the pin code: %s\n",a);
}
What will be the amount of memory allocated in the following cases'?
case 1 input is not chennai,
case 2 input is chennai
Answer: Option A
Q15
char *name = "Delhi";
printf ("%d %d", sizeo (name), sizeof ()*name));
What will be the output?
Answer: Option A
Q16
Which of the following is the correct output for the program given?
main ( )
{
char str [ ]="Sales \0man\0";
printf ("%d %s %d \n", sizeof (str), strlen (str));
}
Answer: Option D
Q17
Which of the following is the correct output for the program given ?
char str [7] = "strings"; printf ("%s", str);
Answer: Option C
Q18
If sizes of a char, an int, a float and a double are 1, 4, 4 and 8 bytes respectively, which of the following is the correct output for the program given below?
{
char ch = 'A';
printf ("%d%d%d", sizeof (ch), sizeof (sizeof('A')), sizeof (3 . 14));
}
Answer: Option B
Q19
What is the value of str3 and sdtr1;
void main ( )
{
char str1 [100] = "united";
char *str2="front";
char *str3;
str3 = strcat (str1, str2)
printf ("\n////5s", str3);
}
Answer: Option B
Q20
Consider the following declarations:
char *a;
char a[5];
Which of the following statements is/are true?
1. both are of pointer type
2. memory allocation is different in both the cases
3. the value of a in drclaration char a [5] can be changed later
Answer: Option A