Bangladesh Computer Council CA Monitoring System Project Exam: 2021প্রশ্ন ও সমাধান
- Set by
- Bangladesh Computer Council CA Monitoring System Project
- Exam date
- 2021
- Questions
- 5 (0 MCQ, 5 written)
- Exam guide
- Government IT officer posts · সরকারি প্রতিষ্ঠানের আইটি পদ
- Programming · প্রোগ্রামিং 3
- Database · ডেটাবেজ 2
What is primary key?
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
Write the create table command for the 'Employee' table with the following column: Emp_ID, Emp_Name, Date_of_Birth.
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
What is the purpose of '\0' character in C?
Model answer
The null character '\0' (ASCII value 0, also called NUL) is a control character used in C to mark the end of a string. A C "string" is really just an array of char — there is no separate string type — so the language needs some marker to know where the meaningful characters stop; '\0' is that marker (a null-terminated string).
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hi"; // stored as {'H','i','\0'} -> occupies 3 bytes
printf("Length: %d\n", (int)strlen(str)); // strlen stops counting at '\0'
printf("Array size: %d\n", (int)sizeof(str));
return 0;
}
Output:
Length: 2
Array size: 3
Why it matters:
- Functions like
strlen(),strcpy(),printf("%s", ...)all scan memory byte-by-byte until they hit'\0'— without it, they would read past the intended data into unrelated memory (undefined behaviour / a buffer over-read). sizeof()counts the terminator too (hence 3, not 2, above), whilestrlen()does not.- Forgetting to reserve space for
'\0'when sizing a char array is a classic C bug (off-by-one buffer overflow).
Exam takeaway: '\0' is the sentinel value that tells C string functions "the string ends here" — every C string must be terminated with it to be used safely.
Write some default data type in C.
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
Write a C program to check the number in EVEN or ODD.
Sign up free to see the model answer · উত্তর দেখতে বিনামূল্যে সাইন আপ করুন
Question text is from the public recruitment exam; answers and explanations are written by ARBS Academy. All past papers · Government IT officer posts guide