-----------------------------------------------------------------------------------------------------------
Previous Page Home Last Page
-----------------------------------------------------------------------------------------------------------
15.
What is the output of this C code?
#include
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}
A. equal
B. unequal
C. Compilation error
D. Depends on the compiler
Answer: B
-----------------------------------------------------------------------------------------------------------
16.
What is the output of this C code?
#include
#include
int main()
{
char *str = "hello, world";
char str1[9];
strncpy(str1, str, 9);
printf("%s %d", str1, strlen(str1));
}
A. hello, world 11
B. hello, wor 9
C. Undefined behaviour
D. Compilation error
Answer: C
-----------------------------------------------------------------------------------------------------------
17.
The return-type used in String operations are.
A. void only
B. void and (char *) only
C. void and int only
D. void, int and (char *) only
Answer: D
-----------------------------------------------------------------------------------------------------------
18.
What is the output of this C code?
#include
int main()
{
char str[10] = "hello";
char *p = strrchr(str, 'l');
printf("%c\n", *(++p));
}
A. l
B. o
C. e
D. Compilation error
Answer: B
---------------------------------------------------------------------------------------------------------
Previous Page Home Last Page
---------------------------------------------------------------------------------------------------------
More Imp Topics:
Array
Preprocessor
Structures
Control Structures
Switch Case
Printf
Variables
File Handling
Previous Page Home Last Page
-----------------------------------------------------------------------------------------------------------
15.
What is the output of this C code?
#include
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}
A. equal
B. unequal
C. Compilation error
D. Depends on the compiler
Answer: B
-----------------------------------------------------------------------------------------------------------
16.
What is the output of this C code?
#include
#include
int main()
{
char *str = "hello, world";
char str1[9];
strncpy(str1, str, 9);
printf("%s %d", str1, strlen(str1));
}
A. hello, world 11
B. hello, wor 9
C. Undefined behaviour
D. Compilation error
Answer: C
-----------------------------------------------------------------------------------------------------------
17.
The return-type used in String operations are.
A. void only
B. void and (char *) only
C. void and int only
D. void, int and (char *) only
Answer: D
-----------------------------------------------------------------------------------------------------------
18.
What is the output of this C code?
#include
int main()
{
char str[10] = "hello";
char *p = strrchr(str, 'l');
printf("%c\n", *(++p));
}
A. l
B. o
C. e
D. Compilation error
Answer: B
---------------------------------------------------------------------------------------------------------
Previous Page Home Last Page
---------------------------------------------------------------------------------------------------------
More Imp Topics:
Array
Preprocessor
Structures
Control Structures
Switch Case
Printf
Variables
File Handling