Read and download free pdf of CBSE Class 12 Computer Science Strings Assignment. Get printable school Assignments for Class 12 Computer Science. Class 12 students should practise questions and answers given here for Strings Computer Science in Class 12 which will help them to strengthen their understanding of all important topics. Students should also download free pdf of Printable Worksheets for Class 12 Computer Science prepared as per the latest books and syllabus issued by NCERT, CBSE, KVS and do problems daily to score better marks in tests and examinations
Assignment for Class 12 Computer Science Strings
Class 12 Computer Science students should refer to the following printable assignment in Pdf for Strings in Class 12. This test paper with questions and answers for Class 12 Computer Science will be very useful for exams and help you to score good marks
Strings Class 12 Computer Science Assignment
Fill ups and Multiple Choice Questions:
Question. What is the length of null string?
Answer: 0 (zero)
Question. Every string must be terminated by __?
Answer: Null Character
Question. Which of the following function is used to reverse the string?
Answer: strrev
Question. Which of the following input function cannot be used to input multiword string?
Answer: scanf()
Question. The function strcmp (“Abcd” ,”ABCD”) will return?
Answer: Negative value
Question. Which of the following function is correct in case of conversion of string digits into their integer value?
a) x =atoi(string)
b) x = stoi(string)
c) x = chartoint(string)
d) all of these
Answer: x =atoi(string)
Question. A string can be stored as an array of ______________
Answer: char
Question. The function strlen(“India is great”) will return the length of string ___________
Answer: 14
Question. __________ function is used to read a complete string.
Answer: gets
Question. _____________ function is used to read a character at a time.
Answer: getchar
Question. How will you declare a string named student with length 50?
Answer: char student[50];
Question. If we consider the string declaration as “char x[10];”, what is the length of the string that can be correctly represented by x?
Answer: 10
Question. If the function strcat(s1,s2) is implemented , then the concatenation will return?
Answer: s2 at the end of s1
Question. Which of the following operation could not be performed on character string with string functions?
a) Combining a string
b) copying a string to another
c) Comparing strings for equality
d) Removing a string
Answer: Removing a string
Question. C does not support the string data type however strings are handled as an array of?
Answer: char
Question. What is missing in this string initialization: char name[8] = {‘r’, ‘a’, ‘e’,‘t’ }?
Answer: \0
Question. To declare and initialized a empty string, a 10 element character array named x, we have char x[10] = “ “ ; What will be the other way for the same?
Answer: char x[10]={‘\0’};
State Whether True or False
Question. A string is represented as array of characters?
Answer: true
Question. strcpy() function is used to copy strings?
Answer: true
Question. To reverse a string, we need two string handling functions strcpy() & strcmp()?
Answer: false
Question. To use string library functions, we have to include header file string.h in our program?
Answer: true
Strings Class 12 Computer Exercise Questions
Question. What is special about the array of char?
Answer: char arrays have special importance in C Language. There is no data type in C to store strings. Therefore, to store string data in, char arrays are being used in C language. To store strings in C, we have to declare char arrays.
For example:
char city[20];
In this example, char array named city has been declared which can store city name with maximum of 20 characters.
Question. What is string?
Answer: String is a combination of one or more characters. It is always enclosed in double quotes. They are terminated by null character (\0) in c. To store strings in c, we use char array. For example: char city[20];
It declares a string variable named city. It can store the string of maximum 20 characters.
Consider another example: char city[20]=”Sunam\0”;
It initializes a string variable named city of length 20 and stores “Sunam” as string value. This value is terminated with null character ‘\0’.
Question. What is the purpose of the null character?
Answer: Null character is also called empty character. It can be represented with the symbol ‘\0’. The length of null character is C is zero. Null character is used to terminate the string in C language. For example: char city[10]= “Sunam\0”;
It declares a string variable named city of length 10 and stores “Sunam” as string value. This value is terminated with null character ‘\0’.
Question. Give the declaration for a string called student, which holds up to 50 characters. Show two ways to initialize the string in the declaration?
Answer: String declaration for student with 50 characters is:
char student[50];
Two methods for declaring strings are:
char student[50]=“Ram\0”;
char student[50]={‘R’, ‘a’, ‘m’,’\0’};
Question. What is the limit of char array?
Answer: Char arrays have a special importance in C language. There is not primitive data type to store string data in c. therefore, to store string values in c, we have to use char arrays. Limit (length) of char array defines the length of string. In c clanguage, maximum length of a string in char array can be 65535. Therefore, we can not extend the limit of char array more than 65535.
Question. What is a difference between “A” and ‘A’?
Answer: “A” is a string while ‘A’ is a character. “A” is string because any string value must be enclosed in double quotes and ‘A’ is char because any char value must be enclosed in single quotes in c language.
Question. Give the difference between putchar() and puts()?
Answer: The difference between putchar() and puts() functions is as follows: puchar() function: This is the unformatted character output function. This function is used to output a single unformatted character on the monitor screen. puts() function: This is the unformatted string output function. This function is used to output an unformatted string on the monitor screen.
Question. List the various functions that can be used to perform the I/O of the string data?
Answer: A string can be read-in or written-out using the input/output functions. Some of the commonly used string input/output functions are explained below:
Reading Strings (String Input Functions):
• scanf() : This function is used to input single word formatted string
• gets() : This function is used to input multiword unformatted string
• getchar() : This function is used to input unformatted single character
Writing Strings (String Output Functions):
• printf() : This function is used to output formatted string
• puts(): This function is used to output unformatted string
• putchar(): This function is used to output unformatted single character
Question. Can we use scanf() to read a string? If no, then give reason. Why it is wrong to use the & symbol when reading in a string with scanf()?
Answer: Yes, we cam use scanf() to read a string. But this function can not be used to inpute multiword strings in C language. There is not data type for storing string data in C. For this, we use char arrays. Name of an array in C represents the address of the first element of array. So, when we use char array in scanf() function, array name itself represents the address of string variable. So, it will be wrong to use the & symbol when reading a string with scanf() function.
Question. What is stored in the str, if each of the following values, separately, is read in using a single call to scanf()? char str[10];
a) cityscape
b) New Delhi
c) one or more blanks
Answer: a) cityscape
b) New
c) one
Question. Explain strlen() function with suitable example.
Answer: Function strlen() stands for string length. This function is used to count the total number of characters in the given string. This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function:
strlen(“punjab”);
This function returns 6 as string length because the string “Punjab” contains 6 characters.
Question. Explain strrev() function with suitable example.
Answer: Function strrev stands for string reverse. This function is used to reverse the given string value. This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function:
strrev(“Punjab”);
It reverses the given string to bajnuP.
Question. Explain strcpy() function with suitable example.
Answer: Function strcpy stands for string copy. This function is used to copy a string value into string variable. This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function.
strcpy(str, “Punjab”);
It copy/store the string value “Punjab” into the string variable str.
Question. Explain strcat() function with suitable example.
Answer: Function strrev stands for string concatenation. This function is used to combines the two strings. It appends 2nd string value at the end of first string value. This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function. Let the two strings are: char str1[10]=“Sunam”; char str2[10]=“City”;
strcat(str2, str1);
It adds value of str1 at the end of str2 and make it – CitySunam
Question. Explain strcmp() function with suitable example.
Answer: Function strcmp stands for string compares. The strcmp( ) function is used to compare two strings. It returns one of the three possible values: zero, negative, or positive. It uses ASCII value of characters to compare strings. The function strcmp() is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Consider the the following example:
If ASCII values of 1st string is equal to ASCII values of 2nd string, It returns 0 e.g. strcmp(“punjab”,“punjab”) returns 0
If ASCII values of 1st string is less than the ASCII values of 2nd string, It returns negative value e.g. strcmp(“india”,“punjab”) return –ve value
If ASCII values of 1st string is greater than ASCII values of 2nd string, It returns +ve value e.g. strcmp(“punjab”,”india”) return +ve value
Question. Explain strupr() function with suitable example.
Answer: Function strupr stands for string upper. This function is used to convert the given string into Upper case (i.e. in capital letter). This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function: strupr(“Punjab”); It converts the given string into PUNJAB.
Question. Explain strlwr() function with suitable example.
Answer: Function strlwr stands for string lower. This function is used to convert the given string into lower case (i.e. in small letter). This function is present in the string.h header file. Therefore, to use this function, we have to include the string.h header file in our program. Following code shows how to use this function: strlwr(“PUNJAB”); It converts the given string into punjab.
Question. Explain atoi () function with suitable example.
Answer: Function atoi stands for ascii to integer. This function converts the string number into integer value. This function is present in the stdlib.h header file. Therefore, to use this function, we have to include the stdlib.h header file in our program. Consider the following example: atoi(“456”); It will convert the string number “456” into integer value 456.
CBSE Class 12 Computer Science Communication And Network Concepts Notes |
CBSE Class 12 Computer Science Strings Assignment
We hope you liked the above assignment for Strings which has been designed as per the latest syllabus for Class 12 Computer Science released by CBSE. Students of Class 12 should download and practice the above Assignments for Class 12 Computer Science regularly. We have provided all types of questions like MCQs, short answer questions, objective questions and long answer questions in the Class 12 Computer Science practice sheet in Pdf. All questions have been designed for Computer Science by looking into the pattern of problems asked in previous year examinations. You can download all Revision notes for Class 12 Computer Science also absolutely free of cost. Lot of MCQ questions for Class 12 Computer Science have also been given in the worksheets and assignments for regular use. All study material for Class 12 Computer Science students have been given on studiestoday. We have also provided lot of Worksheets for Class 12 Computer Science which you can use to further make your self stronger in Computer Science.
What are benefits of doing Assignment for CBSE Class 12 Computer Science Strings?
a. Score higher marks: Regular practice of Computer Science Class 12 Assignments for chapter Strings will help to improve understanding and help in solving exam questions correctly.
b. As per CBSE pattern: All questions given above follow the latest Class 12 Computer Science Sample Papers so that students can prepare as per latest exam pattern.
c. Understand different question types: These assignments include MCQ Questions for Class 12 Computer Science with answers relating to Strings, short answers, long answers, and also case studies.
d. Improve time management: Daily solving questions from Strings within a set time will improve your speed and accuracy.
e. Boost confidence: Practicing multiple assignments and Class 12 Computer Science mock tests for Strings reduces exam stress.
How to Solve CBSE Class 12 Computer Science Strings Assignment effectively?
a. Start with Class 12 NCERT and syllabus topics: Always read the chapter carefully before attempting Assignment questions for Class 12 Computer Science Strings.
b. Solve without checking answers: You should first attempt the assignment questions on Strings yourself and then compare with provided solutions.
c. Use Class 12 worksheets and revision notes: Refer to NCERT Class 12 Computer Science worksheets, sample papers, and mock tests for extra practice.
d. Revise tricky topics: Focus on difficult concepts by solving Class 12 Computer Science MCQ Test.
e. Maintain notebook: Note down mistakes in Strings assignment and read them in Revision notes for Class 12 Computer Science
How to practice CBSE Class 12 Computer Science Strings Assignment for best results?
a. Solve assignments daily: Regular practice of Strings questions will strengthen problem solving skills.
b.Use Class 12 study materials: Combine NCERT book for Class 12 Computer Science, mock tests, sample papers, and worksheets to get a complete preparation experience.
c. Set a timer: Practicing Class 12 Computer Science Strings assignment under timed conditions improves speed and accuracy.
You can download free Pdf assignments for CBSE Class 12 Computer Science Strings from StudiesToday.com
All topics given in Strings Computer Science Class 12 Book for the current academic year have been covered in the given assignment
No, all Printable Assignments for Strings Class 12 Computer Science have been given for free and can be downloaded in Pdf format
Latest syllabus issued for current academic year by CBSE has been used to design assignments for Strings Class 12
Yes, we have provided detailed answers for all questions given in assignments for Strings Class 12 Computer Science