12th (ਕੰਪਿਊਟਰ ਸਾਇੰਸ/Computer Science) - 2026-27

ਪਾਠ-1/Chapter-1
String Function/String Function





Q-1.
ਖਾਲੀ ਸਟਰਿੰਗ (String) ਦੀ ਲੰਬਾਈ ਕੀ ਹੁੰਦੀ ਹੈ ?
What is the length of a blank string?
Q-1. Objective  

1) /1
2) /0
3) /2
4) /4

Ans.) /0

Q-2.
ਹਰ ਸਟਰਿੰਗ (String) ਦੀ ਸਮਾਪਤੀ................ ਨਾਲ ਹੋਣੀ ਚਾਹੀਦੀ ਹੈ ?
Each string should end with ................
Q-2. Objective  

1) ਕੈਰਜ ਵਾਪਸੀ ਚਿਨ੍ਹ /Carriage return sign
2) ਨਵੀ ਰੇਖਾ ਚਿਨ੍ਹ/New line mark
3) ਖਾਲੀ ਚਿਨ੍ਹ /Empty symbol
4) ਲਾਈਨਫੀਡ ਚਿਨ੍ਹ/Linefeed symbol

Ans.) ਨਵੀ ਰੇਖਾ ਚਿਨ੍ਹ/New line mark

Q-3.
ਸਟਰਿੰਗ (string) ਨੂੰ ਉਲਟਣ ਲਈ ਕਿਹੜੇ ਨਿਮਾਨਲਿਖਤ ਫੰਕਸ਼ਨਾਂ (function) ਦਾ ਇਸਤੇਮਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ?
Which of the following functions is used to reverse the string?
Q-3. Objective  

1) /strcpy
2) /strlen
3) /strcmp
4) /None of these

Ans.) /None of these

Q-4.
ਜੇਕਰ ਅਸੀਂ ਵਿਚਾਰ ਕਰੀਏ ਕਿ ਸਟਰਿੰਗ ਦਾ ਐਲਾਨ char x[10] ਵਜੋਂ ਹੁੰਦਾ ਹੈ ਤਾਂ ਉਸ ਸਟਰਿੰਗ ਦੀ ਲੰਬਾਈ ਦੀ ਕਿੰਨੀ ਹੁੰਦੀ ਹੈ ਜਿਹੜੀ x ਦੁਆਰਾ ਸਹੀ ਤੌਰ ਤੇ ਪ੍ਰਤੀਨਿਧ ਕੀਤੀ ਜਾ ਸਕਦੀ ਹੈ ?
If we consider that a string is declared as char x [10], what is the length of the string that can be properly represented by x?
Q-4. Objective  

1) /11
2) /9
3) /10
4) /All of these

Ans.) /9

Q-5.
ਨਿਮਨਲਿਖਤ ਵਿਚ ਕਿਹੜੇ ਇਨਪੁਟ ਫੰਕਸ਼ਨ (Function) ਬਹੁ ਸ਼ਬਦੀ ਸਟਰਿੰਗ (String) ਦੇ ਲਈ ਨਹੀਂ ਵਰਤੇ ਜਾ ਸਕਦੇ ?
Which of the following input functions cannot be used for multi-word strings?
Q-5. Objective  

1) /getch()
2) /gets()
3) /scanf()
4) /None of these

Ans.) /scanf()

Q-6.
ਇਨ੍ਹਾਂ ਵਿੱਚੋ ਕਿਹੜਾ ਸਹੀ ਹੈ, ਜੇਕਰ ਅਸੀਂ ਲਿਖਦੇ ਹਾਂ strcmp (s1,s2) ਕਿਹੜਾ ਮੁੱਲ ਵਾਪਿਸ ਹੁੰਦਾ ਹੈ।
Which of these is correct, if we type strcmp (s1, s2) which value is returned?
Q-6. Objective  

1) /<0 when s1<s2
2) /=0 when s1=s2
3) />0 when s1 > s2
4) /All of these

Ans.) /All of these

Q-7.
ਜੇਕਰ ਫੰਕਸ਼ਨ (function) strcat (s1,s2) ਲਾਗੂ ਹੁੰਦਾ ਹੈ ਤਦ concatenate ਜੋ ਵਾਪਸ ਕਰੇਗਾ।
If the function strcat (s1, s2) is applied then the concatenate will return.
Q-7. Objective  

1) /s2 at the end of s2
2) /s2 at the end of s1
3) /s1 at the end of s2
4) /s2 at the start of s1

Ans.) /s2 at the end of s1

Q-8.
ਜੇਕਰ ਫੰਕਸ਼ਨ (function) strcmp (Abcd,ABCD) ਕੀ ਮੋੜੇਗਾ ?
What if the function strcmp (Abcd, ABCD) returns?
Q-8. Objective  

1) /-1
2) /0
3) /1
4) /None of these

Ans.) /0

Q-9.
ਸਟਰਿੰਗ (string) ਫੰਕਸ਼ਨਾਂ (Functions) ਦੇ ਨਾਲ ਚਿਨ੍ਹ ਸਟਰਿੰਗ (string) ਤੇ ਕਿਹੜੇ ਨਿਮਾਨਲਿਖਤ ਕੰਮ ਨਹੀਂ ਕੀਤੇ ਜਾ ਸਕਦੇ ?
Which of the following functions cannot be done on a symbol string with string functions?
Q-9. Objective  

1) ਇਕ ਸਟਰਿੰਗ ਨੂੰ ਜੋੜਨਾ /concatenate a string
2) ਇਕ ਸਟਰਿੰਗ ਦੀ ਦੂਜੀ ਨਾਲ ਕਾਪੀ ਕਰਨੀ/Copy from one string to another
3) ਬਰਾਬਰਤਾ ਲਈ ਸਟਰਿੰਗਜ਼ ਦਾ ਮੁਕਾਬਲਾ ਕਰਨਾ/Compare strings for equality
4) ਇਕ ਸਟਰਿੰਗ ਨੂੰ ਹਟਾਉਣਾ/Deleting a string

Ans.) ਇਕ ਸਟਰਿੰਗ ਨੂੰ ਹਟਾਉਣਾ/Deleting a string

Q-10.
ਸਟਰਿੰਗ ਅੰਕਾਂ ਨੂੰ ਉਨ੍ਹਾਂ ਦੇ ਪੂਰਣ ਮੁੱਲ ਵਿਚ ਬਦਲਣ ਲਈ ਨਿਮਾਨਲਿਖਤ ਚੋ ਕਿਹੜਾ ਫੰਕਸ਼ਨ (function) ਸਹੀ ਹੈ ?
Which function of the following is correct for converting string numbers to their integer values?
Q-10. Objective  

1) /x=atoi(string)
2) /x=stoi(string)
3) /x=chartoint(string)
4) /All of these

Ans.) /x=atoi(string)

Q-11.
ਇਕ ਸਟਰਿੰਗ (string) ਨੂੰ ਚਿਨ੍ਹਾ ਦੀ ਐਰੇ ਨਾਲ ਦਰਸਾਇਆ ਜਾ ਸਕਦਾ ਹੈ ?
Can a string be represented by an array of symbols?
Q-1. True/False  

1) ਸਹੀ/True
2) ਗਲਤ/False

Ans.) ਸਹੀ/True

Q-12.
ਇਕ ਸਟਰਿੰਗ (string) ਨੂੰ ਆਮ ਐਰੇ ਦੀ ਵਾਕ-ਰਚਨਾ ਵਾਂਗ ਹੀ ਕੇਵਲ ਸਟਰਿੰਗ (string) ਚਿਨ੍ਹਾ ਨਾਲ ਆਰੰਭ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ ?
Can a string just start with a string symbol, just like the syntax of a common array?
Q-2. True/False  

1) ਸਹੀ/True
2) ਗਲਤ/False

Ans.) ਗਲਤ/False

Q-13.
strcmp ਕਾਪੀ ਸਟਰਿੰਗਜ਼ (strings) ਵਿਚ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ ?
strcmp copy is used in strings?
Q-3. True/False  

1) ਸਹੀ/True
2) ਗਲਤ/False

Ans.) ਗਲਤ/False

Q-14.
ਇਕ ਸਟਰਿੰਗ (string) ਨੂੰ ਉਲਟਣ ਲਈ ਸਾਨੂੰ ਦੋ ਸਾਂਭ ਸੰਭਾਲ ਦੇ ਫੰਕਸ਼ਨ (function) ਜਿਵੇ strcpy() ਅਤੇ strcmp() ਚਾਹੀਦੇ ਹੁੰਦੇ ਹਨ ?
To reverse a string, we need two maintenance functions like strcpy () and strcmp ().
Q-4. True/False  

1) ਸਹੀ/True
2) ਗਲਤ/False

Ans.) ਗਲਤ/False

Q-15.
ਸਟਰਿੰਗ (string) ਲਾਈਬ੍ਰੇਰੀ ਫੰਕਸ਼ਨ (function) ਦੀ ਵਰਤੋਂ ਲਈ ਆਪਣੇ ਪ੍ਰੋਗਰਾਮ ਵਿਚ ਹੈਡਰ ਫਾਈਲ string.h ਦੀ ਵਰਤੋਂ ਕਦਰਦੇ ਹਾਂ ?
How do we use the header file string.h in our program to use the string library function?
Q-5. True/False  

1) ਸਹੀ/True
2) ਗਲਤ/False

Ans.) ਸਹੀ/True