# Siruri De Caractere

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Laurentiu_lambri
L
Laurentiu_lambri
Community Contributor
Quizzes Created: 6 | Total Attempts: 9,343
Questions: 9 | Attempts: 1,648

Settings

Fisa de lucruri pentru siruri de caractere in C++

• 1.

### Se consideră declararea char e[20]=”51+73”; Care este şirul memorat de variabila e după executarea instrucţiunii de mai jos? strcpy(e,strchr(e,’+’)) ;

+73
Explanation
The strcpy function is used to copy a string from one location to another. In this case, the source string is "51+73" and the destination string is "e". The strchr function is used to find the first occurrence of a character in a string. In this case, it is used to find the "+" character in the source string. The strchr function returns a pointer to the first occurrence of the character, so the strcpy function will copy everything after the "+" character into the destination string "e". Therefore, the value of "e" after the execution of the instruction will be "+73".

Rate this question:

• 2.

### Ce se va afişa în urma executării secvenţei de program alăturate, considerând că s este o variabilă şir de caractere, iar i o variabilă de tip întreg? char a[10]="xmn"; for (i=0;i<=2;i++) strcpy(a+i,a+i+1); cout<<a;

• A.

Xmn

• B.

Eae

• C.

Men

• D.

Examen

A. Xmn
Explanation
The given code snippet initializes a character array "a" with the string "xmn". Then, a loop is executed three times, where the strcpy function is used to copy the character at index "i+1" to the character at index "i" in the array "a". Finally, the content of the array "a" is printed using the cout statement.

In each iteration of the loop, the characters are shifted one position to the left. After the loop finishes executing, the array "a" will contain the string "xmn", which is the correct answer.

Rate this question:

• 3.

### Se consideră variabila s care memorează şirul de caractere CARACATITA. Ce valoare va avea s după executarea instrucţiunii de mai jos? strcpy(s,strstr(s,"TI"));

TITA
Explanation
The function `strstr(s, "TI")` searches for the first occurrence of the substring "TI" in the string `s`. The `strcpy(s, ...)` function then copies the found substring and replaces the original string `s` with it. Therefore, after executing the instruction `strcpy(s, strstr(s, "TI"))`, the value of `s` will be "TITA".

Rate this question:

• 4.

### Variabila s este de tip şir de caractere, iar variabilele c1 şi c2 sunt de tip char. Care expresie are valoarea 1 dacă şi numai dacă şirul de caractere s conţine caracterele memorate de variabilele c1 şi c2?

• A.

Strstr(s,c1+c2)!=0

• B.

Strchr(strchr(s,c1),c2)!=0

• C.

Strchr(s,c1)!=0 && strchr(s,c2)!=0

• D.

Strchr(s,c1)*strchr(s,c2)!=0

C. Strchr(s,c1)!=0 && strchr(s,c2)!=0
Explanation
The expression "strchr(s,c1)!=0 && strchr(s,c2)!=0" has the value of 1 if and only if the string of characters "s" contains both the characters stored in variables "c1" and "c2".

Rate this question:

• 5.

### Fie sirul de caractere s[15]="abracadabra". Ce valoare s-ar afisa la executia intructiunii cout<<strlen(s);

• A.

15

• B.

11

• C.

0

• D.

10

B. 11
Explanation
The correct answer is 11. In this question, the string "abracadabra" is assigned to the character array s[15]. The strlen() function is used to determine the length of the string, which is the number of characters in the string excluding the null character. Since "abracadabra" has 11 characters, the value 11 would be displayed when executing the cout

Rate this question:

• 6.

### Fie sirul cuv, avand urmatorul continut: "portocala". Precizati care va fi continutul acestuia dupa executarea instructiunilor strcpy(a+2 , a+6); a[2]=NULL;

• A.

Poala

• B.

Porla

• C.

Po

• D.

Poa

C. Po
Explanation
The given code snippet is using the strcpy function to copy the characters starting from the 6th position of the string "portocala" into the 2nd position of the same string. After executing this instruction, the string will become "poporala". Then, the code assigns NULL to the 3rd position of the string, resulting in the final content of the string being "po".

Rate this question:

• 7.

### Precizati ce efect ar avea executarea intructiunii cout<<strstr(a,b); daca a="obiect" , b="ie".

• A.

Iect

• B.

Ct

• C.

2

• D.

3

A. Iect
Explanation
The execution of the statement "cout

Rate this question:

• 8.

### Variabila s a fost declarată astfel: char s[20]; Ce se afișează după executarea secvenței de mai jos?   strcpy(s,˝bacalaureat˝); cout<<s;

• A.

R

• B.

E

• C.

7

• D.

8

A. R
Explanation
The given code declares a character array variable named "s" with a size of 20. Then, the strcpy function is used to copy the string "bacalaureat" into the variable "s". Finally, the content of variable "s" is printed using the cout statement. Therefore, after executing the given code, the output will be the character 'r'.

Rate this question:

• 9.

### Considerăm variabila x care memorează şirul de caractere "ABAC". Care dintre următoarele instrucţiuni conduc la afişarea caracterului B ?

• A.

Cout<<x[1];

• B.

Cout<<x[2];

• C.

Cout<<x;

• D.

Cout<<x[3];

A. Cout<<x[1];
Explanation

Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

• Current Version
• Mar 21, 2023
Quiz Edited by
ProProfs Editorial Team
• Oct 18, 2011
Quiz Created by
Laurentiu_lambri