Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Strings Questions
C#.NET — choose the valid ways to convert a Single (float) to a String.
C#.NET strings — select the correct statement about strings.
C#.NET strings — evaluate the output of: String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2);
C#.NET — Determine the correct output for the code: String s1 = "Kicit"; Console.Write(s1.IndexOf('c') + " "); Console.Write(s1.Length);
C strings and the null terminator: what does this program print? #include
#include
int main() { static char s[] = "Hello!"; printf("%d ", *(s + strlen(s))); return 0; }
Nested standard-library calls: what does this program print after strcat then strcpy? #include
#include
int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s ", strcpy(str2, strcat(str1, str2))); return 0; }
Comparing two distinct C arrays of identical contents: what does this program print? #include
int main() { char str1[] = "Hello"; char str2[] = "Hello"; if (str1 == str2) printf("Equal "); else printf("Unequal "); return 0; }
In C, what will be the exact output of this program (note the embedded nulls and how strlen works)? #include
#include
int main() { char str[] = "India\0\CURIOUSTAB\0"; printf("%d ", strlen(str)); return 0; } Choose the correct value printed by strlen.
In C, what does this program print with %s given embedded null bytes inside the array literal? #include
#include
int main() { char str[] = "India\0\CURIOUSTAB\0"; printf("%s ", str); return 0; } Select the exact output.
In C, consider strcmp on two user-entered strings using gets (unsafe). What output should you expect from this program and why can it vary? #include
#include
int main() { char str1[5], str2[5]; int i; gets(str1); gets(str2); i = strcmp(str1, str2); printf("%d ", i); return 0; } Choose the most accurate description of the printed value.
C printf with extra arguments: what will this program print when the format string contains no conversion specifiers? #include
int main() { printf("India", "CURIOUSTAB "); return 0; } Select the exact output that appears.
In C, swapping two pointers to string literals inside an array: what exactly does this program print? #include
int main() { char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"}; int i; char *t; t = names[3]; names[3] = names[4]; names[4] = t; for (i = 0; i <= 4; i++) printf("%s,", names[i]); return 0; } Choose the correct comma-separated order.
Indexing tricks and side effects in C: determine the precise characters printed by this code involving pre/post increment and the i[s] notation. #include
int main() { static char s[25] = "The cocaine man"; int i = 0; char ch; ch = s[++i]; printf("%c", ch); ch = s[i++]; printf("%c", ch); ch = i++[s]; printf("%c", ch); ch = ++i[s]; printf("%c", ch); return 0; } Choose the exact 4-character output.
Recursive I/O with getchar and printing on unwinding: if the user inputs the characters a, b, c followed by Enter, what will this program print? #include
int main() { void fun(); fun(); printf(" "); return 0; } void fun() { char c; if ((c = getchar()) != ' ') fun(); printf("%c", c); } Select the exact output sequence.
String reversal using indexing: what does this C program output after reading a line with gets and then printing characters in reverse order? #include
#include
int main() { char sentence[80]; int i; printf("Enter a line of text "); gets(sentence); for (i = strlen(sentence) - 1; i >= 0; i--) putchar(sentence[i]); return 0; } Identify the correct behavior.
Array indexing into a string literal in C: what character does this code print? #include
#include
int main() { printf("%c ", "abcdefgh"[4]); return 0; } Pick the exact character output.
Pointer types and %s in printf: what happens when you pass &str + 2 (a pointer to beyond the array) to %s? #include
int main() { char str[25] = "CuriousTab"; printf("%s ", &str + 2); return 0; } Select the most accurate outcome.
C strings and strcat on string literals (Turbo C, 16-bit DOS): what will the following program print or do? #include
#include
int main() { char *str1 = 'India'; char *str2 = 'CURIOUSTAB'; char *str3; str3 = strcat(str1, str2); // concatenating into a string literal printf('%s %s ', str3, str1); return 0; } Assume a Turbo C compiler on a 16-bit DOS platform, as originally intended.
C printf return value and empty strings: what does this program print? #include
int main() { int i; char a[] = '\0'; // empty C string if (printf('%s', a)) printf('The string is not empty '); else printf('The string is empty '); return 0; }
Addresses of string literals and %s printing: given that the memory address of the literal 'Hello1' is 1022 (Turbo C, 16-bit DOS), what will this print? #include
int main() { printf('%u %s ', &'Hello1', &'Hello2'); return 0; }
1
2
3