Recent questions tagged strings

9 9 votes
2 2 answers
269
269 views
What is the output of the following code?#include <stdio.h void fun(int *p) { *p = *p + 1; p++; *p = *p + 2; } int main() { int arr[] = {5, 10, 15}; fun(arr + 1); printf(...
9 9 votes
2 2 answers
266
266 views
What is the output of the following code?#include <stdio.h void update(int a[]) { a[0] = a[0] + a ; *(a + 1) = *(a + 1) + 5; } int main() { int arr[] = {2, 4, 6}; update(...
9 9 votes
2 2 answers
230
230 views
What is the output of the following code?#include <stdio.h void change(char *p) { p = 'X'; *(p + 3) = '\0'; } int main() { char str[] = "GATE"; change(str); printf("%s",...
7 7 votes
2 2 answers
204
204 views
What is the output of the following code?#include <stdio.h int main() { char str[] = "HELLO"; char *p = str + 1; *(p + 2) = 'A'; printf("%s %c", str, *p); return 0; }$\te...
6 6 votes
2 2 answers
196
196 views
What is the output of the following code?#include <stdio.h int main() { char str[] = {'C', 'S', 'E', '\0', 'X'}; printf("%s %c", str, str[4]); return 0; }$\texttt{CSE X}$...
2 2 votes
1 1 answer
117
117 views
Consider the following Python code:a = " #GATE #" b = " *DA *" print(a.lstrip("#"), a.rstrip("#"), b.lstrip("*").rstrip("*"))What is the output of the code above? #GATE G...
3 3 votes
2 2 answers
113
113 views
Consider the following Python code:s = "GO Classes for GATE DA" parts = s.split() print(parts , parts[-2] + parts[-1], len(parts))What is the output of the code above?GO ...
1 1 vote
1 1 answer
93
93 views
Consider the following Python code:s = "abcdefg" part1 = s[5:1:-2] part2 = s[::-3] print(part1, part2)What is the output of the code above?fdb gdafd gdafd gadeg gda
2 2 votes
1 1 answer
100
100 views
Consider the following Python code:s = "GOClasses" a = s[:2] b = s[2:] c = s[:0] d = s[5:] print(a + b, c == "", d)What is the output of the code above?GO True ClassesGOC...
2 2 votes
1 1 answer
105
105 views
Consider the following Python code:s = "HelloWorld" a = s[6:2] b = s[3:3] print(a == b, len(a + b))What is the output of the code above?True 0False 0True 2IndexError
4 4 votes
1 1 answer
127
127 views
Consider the following Python code:s = "GOClasses" first = s[0] last = s[len(s) - 1] middle = s[len(s) // 2] print(first + middle + last)What is the output of the code ab...
1 1 vote
1 1 answer
110
110 views
Consider the following Python code:print("Gate" < "gate", "DA" < "Data", "abc" "ab")What is the output of the code above?True True TrueFalse True TrueTrue False TrueTrue...
1 1 vote
1 1 answer
98
98 views
Consider the following Python code:text = "banana bandana" a = text.find("ana") b = text.find("ana", a + 1) c = text.find("xyz") print(a, b, c)What is the output of the c...
2 2 votes
1 1 answer
90
90 views
Consider the following Python code:a = " GATE DA " b = " *Data *" print(a.strip() + "-" + b.strip("*").lower())What is the output of the code above?GATE DA-dataGATE DA -d...
1 1 vote
2 2 answers
122
122 views
Consider the following Python code:s = "GATE Data" result = s.lower().replace("gate", "GO").capitalize() print(result)What is the output of the code above?GO dataGo datag...
3 3 votes
1 1 answer
113
113 views
Consider the following Python code:s = "python" t = s s = s[:2] + "X" + s[3:] print(s, t)What is the output of the code above?pyXhon pythonpyXhon pyXhonpython pythonTypeE...
4 4 votes
1 1 answer
95
95 views
Consider the following Python code:s1 = "Data" s2 = s1 + "base" pattern = "ta" + ("b" * 1) + "ase" tag = s1 + "!" * 2 print(s1 in s2, pattern in s2, "data" in s2, tag)Wha...
3 3 votes
1 1 answer
88
88 views
Consider the following Python code:s = "PythonDPP" print(s[-2:-8:-2])What is the output of the code above?PnhPDtPPDnohty
3 3 votes
1 1 answer
97
97 views
Consider the following Python code:s = "GATE2027" part1 = s[1:7:2] part2 = s[:4] print(part1 + part2)What is the output of the code above?AE0GATEAT2GATEAE2GATEATE202
3 3 votes
1 1 answer
99
99 views
Consider the following Python code:s = "GOClassesforGateDA" result = s + s[-3] + s[len(s) - 1] print(result)What is the output of the code above?CeACDAOeACss
0 0 votes
2 2 answers
268
268 views
Which of the following is not a palindromic subsequence of the string "$\text{ababcdabba}$"?$\text{abcba}$$\text{abba}$$\text{abbbba}$$\text{adba}$
35 35 votes
7 7 answers
14.1k
14.1k views
​​​​​Consider the following C program:#include <stdio.h void stringcopy (char *, char *); int main() { char a[30] = "@#Hello World!"; stringcopy(a, a+2); printf("%s\n",a)...
2 2 votes
2 2 answers
888
888 views
From a character string of length m , the number of sub-strings of all lengths that can be formed are:$\mathrm{m}^{2}$$\mathrm{m}$$\mathrm{m}(\mathrm{m}+1) / 2$$\mathrm{m...
0 0 votes
1 1 answer
528
528 views
Why we should or should not include null string in this count ?
5 5 votes
1 1 answer
866
866 views
The provided C code is a version of the C string library function strlen(), which calculates the length of a given string.unsigned int mystrlen(char *c) { unsigned in...