CCP 2025 Regular Solved Question Paper Computer Concepts & C Programming
Time: 3 Hrs | Max. Marks: 80
Section - A
I. Answer any TEN questions. (10×2=20)
1. Define Computer.
A computer is an electronic device that processes data under the control of a set of instructions called a program to produce meaningful output.
2. Define Software. Mention its types.
Software is a set of instructions or programs that tell the hardware what to do.
Types:
System Software
Application Software
3. Give any two differences between Compiler and Interpreter.
Compiler | Interpreter |
---|---|
Translates the whole program at once. | Translates program line-by-line. |
Faster execution after compilation. | Slower execution as it interprets line-by-line. |
4. Write features of 'C' language.
It is a structured and procedural programming language.
It supports low-level memory access using pointers.
It is fast and efficient.
It is widely used for system and application development.
5. What are Keywords? Give Example.
Keywords are predefined reserved words in C that have special meanings.
Example: int, return, while
6. Define Datatypes. Mention its types.
Datatypes define the type and size of data that a variable can hold in a programming language, determining the operations that can be performed on it.
Types in C:
- Basic Datatypes: int (integer), float (floating-point), char (character), double (double precision floating-point).
- Derived Datatypes: Arrays, Pointers, Structures, Unions.
- Void Datatype: Represents no value (used in functions or pointers).
7. List any two Mathematical library functions in 'C' with their process.
1. sqrt()
- Header: <math.h>
- Process: Returns the square root of a given non-negative number.
Example: double result = sqrt(16); // Returns 4.0
2. pow()
- Header: <math.h>
- Process: Calculates the value of a base raised to an exponent.
Example: double result = pow(2, 3); // Returns 8.0 (2^3)
8. Write difference between getchar() & putchar().
getchar() | putchar() |
---|---|
Reads a single character from standard input (e.g., keyboard). | Outputs a single character to standard output (e.g., screen). |
Returns the character as an integer (int ) or EOF on error/end-of-file. | Takes a character as input and displays it; returns the character or EOF . |
Takes no parameters. | Takes one character as a parameter. |
Used to read one character at a time from the user. | Used to print one character at a time to the screen. |
Example: int c = getchar(); | Example: putchar('A'); |
9. Write a process of Go To Statement.
The goto statement in C transfers program control to a labeled statement within the same function.
Process:
- Define a label using a name followed by a colon (e.g., label:).
- Use goto label; to jump to the labeled statement.
- The program continues execution from the labeled point.
10. Describe simple if with Example.
The simple if statement in C executes a block of code if a specified condition is true.
Syntax:
if (condition)
{
// Code to execute if condition is true
}
Example:
#include <stdio.h>
int main() {
int num = 10;
if (num > 0)
{
printf("Number is positive\n");
}
return 0;
}
11. What is array? How to initialize array.
An array is a collection of elements of the same datatype stored in contiguous memory locations, accessed using an index starting from 0.
Initialization :
int arr[5] = {10, 20, 30, 40, 50};
12. Define String Constants.
A string constant (or string literal) is a sequence of characters enclosed in double quotes (” “) in a programming language like C. It is stored as an array of characters terminated by a null character (\0).
Section - B
II. Answer any FOUR of the following. (4×5=20)
13. Explain the Block Diagram of Computer System.

A block diagram of a computer system shows the main parts of a computer and how they work together to perform tasks. The major components are:
1. Input Unit: This unit takes data from the user through devices like a keyboard or mouse and sends it to the computer for processing.
2. Central Processing Unit (CPU): The CPU is the brain of the computer and has two parts:
Control Unit (CU): Directs the flow of data and instructions.
Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations.
3. Memory Unit: Stores data and instructions. It includes:
Primary Memory (RAM/ROM): Temporarily stores data while the computer is on.
Secondary Storage (HDD, SSD): Stores data permanently.
4. Output Unit: After processing, results are sent to output devices like a monitor or printer to display the information to the user.
14. Write a C program to find the largest of three numbers.
#include<stdio.h>
int main()
{
float a, b, c;
printf("Enter three numbers: ");
scanf("%f %f %f", &a, &b, &c);
if (a >= b && a >= c)
{
printf("Largest number is %.2f\n", a);
}
else if (b >= a && b >= c)
{
printf("Largest number is %.2f\n", b);
}
else
{
printf("Largest number is %.2f\n", c);
}
return0;
}
15. Explain any five string handling library functions.
strlen()
– Returns the length of the string (excluding\0
).strcpy()
– Copies one string into another.strcat()
– Appends one string to the end of another.strcmp()
– Compares two strings and returns the result.strchr()
– Finds the first occurrence of a character in a string.
String handling functions in C are defined in the header file <string.h>
. Below are five key functions commonly used:
strlen(str)
Define: Returns the length of the string
str
, excluding the null terminator\0
.Example:
int len = strlen("Hello"); // Returns 5
strcpy(dest, src)
Define: Copies the string
src
(including the null terminator) intodest
.Example:
char dest[20]; strcpy(dest, "Hello"); // dest now contains "Hello"
strcat(dest, src)
Define: Appends the string
src
to the end ofdest
, overwriting the null terminator indest
. The resulting string is null-terminated.Example:
char dest[20] = "Hello"; strcat(dest, " World"); // dest becomes "Hello World"
strcmp(str1, str2)
Define: Compares the two strings
str1
andstr2
lexicographically.Returns
0
if the strings are equalReturns a negative value if
str1 < str2
Returns a positive value if
str1 > str2
Example:
int result = strcmp("abc", "abc"); // Returns 0
=strchr(str, ch)
Define: Returns a pointer to the first occurrence of the character
ch
in the stringstr
. ReturnsNULL
if the character is not found.Example:
char *pos = strchr("Hello", 'l'); // Points to the first 'l' in "Hello"
16. Explain the Syntax of Switch statement with example.
The switch statement in C allows multi-way branching by evaluating an expression and executing the corresponding case block.
Syntax:
switch (expression)
{
case constant1:
// Code for constant1
break;
case constant2:
// Code for constant2
break;
default:
// Code if no case matches
}
Example:
#include <stdio.h>
int main()
{
int day = 3;
switch (day)
{
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednesday\n");
break;
default:
printf("Invalid day\n");
}
return 0;
}
Output: Wednesday
17. Differentiate between Structure and Union.
Structure | Union |
---|---|
Uses separate memory for each member. | Shares the same memory for all members. |
All members can be accessed at the same time. | Only one member can be used at a time. |
Size = sum of all members’ sizes. | Size = size of the largest member only. |
Changing one member does not affect others. | Changing one member affects the others. |
Syntax: struct Student { ... }; | Syntax: union Data { ... }; |
More memory is used. | Less memory is used (memory efficient). |
Section - C
III. Answer any Four of the following questions. (4×10-40)
18. Define Programming Languages. Explain the Different Types of Programming Languages.
1. Machine Language (Low-Level Language)
This is the first-generation language, and it uses binary code (0s and 1s) to communicate directly with the hardware.
Programs written in machine language are hardware dependent and extremely difficult for humans to write or debug.
Example:
10110000 01100001
(binary instruction)
Advantages: Fast execution speed
Disadvantages: Difficult to understand, write, and debug
2. Assembly Language
This is a second-generation language that uses mnemonics (short codes or symbols) instead of binary.
It is one level above machine language and needs an assembler to convert it into machine code.
Example:
MOV A, B
(move data from B to A)
Advantages: Easier than machine language, more readable
Disadvantages: Still hardware dependent, not portable
3. High-Level Language
These are third-generation languages that are human-readable and close to English.
They are platform-independent and need to be translated into machine code using compilers or interpreters.
Examples: C, C++, Java, Python, BASIC
Advantages: Easy to learn, portable, readable, and efficient for complex software
Disadvantages: Slower than low-level languages due to translation step
4. Fourth-Generation Language (4GL)
These are very high-level languages designed to be closer to human language.
They are often used for database query, report generation, and application development.
Examples: SQL, MATLAB, Oracle Reports
Advantages: Requires less coding, easy to develop applications
Disadvantages: Less flexible for complex system-level programming
5. Scripting Languages
These are used to automate tasks or enhance web pages.
They are interpreted rather than compiled.
Examples: JavaScript, PHP, Python, Perl
Advantages: Easy to learn and use for automation
Disadvantages: Slower execution compared to compiled languages
19. Explain formatted and unformatted I/P and O/P functions with examples.
formatted I/O Functions:
Formatted I/O functions allow precise control over the input and output format, such as specifying the number of decimal places, field width, or data type. They use format specifiers (e.g., %d for integers, %f for floats) to define how data is read or displayed.
Characteristics
Allow formatting of data (e.g., alignment, precision, padding).
Use format specifiers to interpret or display data in a specific way.
Commonly used in C: scanf() for input, printf() for output.
In C++: cin with manipulators (e.g., setw, setprecision) for input, cout for output.
Examples
C – Formatted Input with scanf()
#include <stdio.h>
int main() {
int age;
float salary;
printf("Enter age and salary:");
scanf("%d %f", &age, &salary); // Reads an integer and a float
printf("Age: %d, Salary: %.2f\n", age, salary); // Displays with 2 decimal places
return 0;
}
Explanation:
scanf(“%d %f”, &age, &salary) reads an integer (%d) and a float (%f) from the user.
printf(“Age: %d, Salary: %.2f\n”, age, salary) displays the integer as is and the float with two decimal places (.2f).
Unformatted I/O Functions:
Unformatted I/O functions handle raw data, typically characters or strings, without using format specifiers. They are simpler but offer less control over data formatting.
Characteristics
Deal with raw character or string data.
No format specifiers; data is read or written as-is.
In C: getchar(), putchar(), gets(), puts() are common.
In C++: cin.get(), cin.getline(), cout.put() are used.
Examples
C – Unformatted Input/Output with getchar() and putchar()
#include <stdio.h>
int main()
{
char ch;
printf("Enter a character: ");
ch = getchar(); // Reads a single character
printf("You entered: ");
putchar(ch); // Outputs a single character
printf("\n");
return 0;
}
Explanation:
getchar() reads a single character from the user.
putchar(ch) outputs the character as-is, without formatting.
Differences:
Formatted I/O | Unformatted I/O |
---|---|
Offers precise control over data format. | No formatting; handles raw data. |
C Examples: printf , scanf | C Examples: getchar , putchar , gets , puts |
C++ Examples: cin with manipulators, cout | C++ Examples: cin.get , cin.getline , cout.put |
Used when specific formatting is needed (e.g., decimals). | Used for simple character or string input/output. |
More complex due to format specifiers. | Simpler, direct data handling. |
20. Explain in Detail types of operators with examples.
An operator is a symbol that performs operations on variables and values in a program. Operators are used in expressions to manipulate data. The major types of operators are:
1. Arithmetic Operators:
These operators are used to perform mathematical operations like addition, subtraction, multiplication, division, and modulus.
Example: a + b
, a - b
, a * b
, a / b
, a % b
2. Relational Operators (Comparison Operators):
These operators are used to compare two values and return true or false.
Example: a == b
, a != b
, a > b
, a < b
, a >= b
, a <= b
3. Logical Operators:
Used to combine two or more conditions. The result is either true or false.
Example: a > 5 && b < 10
, a == b || a == c
, !(a < b)
4. Assignment Operators:
These operators are used to assign values to variables.
Example: a = 10
, a += 5
, a -= 2
, a *= 3
, a /= 2
, a %= 3
5. Increment and Decrement Operators:
These are used to increase or decrease a variable’s value by 1.
Example: a++
, ++a
, a--
, --a
6. Bitwise Operators:
These operators perform operations on the binary values of numbers.
Example: a & b
, a | b
, a ^ b
, ~a
, a << 2
, a >> 1
7. Conditional (Ternary) Operator:
It is a shorthand for if-else statement and used to choose between two values.
Syntax: condition ? value_if_true : value_if_false
Example: max = (a > b) ? a : b
8. Special Operators:
These include operators like sizeof
, &
(address of), *
(pointer), and ->
(structure pointer).
Example: sizeof(int)
, &a
, *p
, ptr->x
Operators in programming are symbols that perform operations on variables and values. They’re like tools to do math, compare values, or manipulate data.
1. Arithmetic Operators
Definition: Used to perform basic mathematical operations.
Example Program:
#include <stdio.h>
int main() {
int a = 10, b = 5;
printf("Addition = %d\n", a + b);
printf("Multiplication = %d\n", a * b);
return 0;
}
2. Relational Operators
Definition: Used to compare two values.
Example Program:
#include <stdio.h>
int main() {
int a = 10, b = 20;
if (a < b) {
printf("a is less than b\n");
}
return 0;
}
3. Logical Operators
Definition: Used to combine two or more conditions.
Example Program:
#include <stdio.h>
int main() {
int a = 5, b = 10;
if (a < b && b < 20) {
printf("Both conditions are true\n");
}
return 0;
}
4. Assignment Operators
Definition: Used to assign values to variables.
Example Program:
#include <stdio.h>
int main() {
int a = 10;
a += 5; // a = a + 5
printf("Updated value of a = %d\n", a);
return 0;
}
5. Increment and Decrement Operators
Definition: Used to increase or decrease value by 1.
Example Program:
#include <stdio.h>
int main() {
int a = 10;
a++;
printf("After increment: %d\n", a);
return 0;
}
6. Bitwise Operators
Definition: Used to perform bit-level operations.
Example Program:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("a & b = %d\n", a & b);
return 0;
}
7. Conditional (Ternary) Operator
Definition: Short form of if-else to choose between two values.
Example Program:
#include <stdio.h>
int main() {
int a = 10, b = 20;
int max = (a > b) ? a : b;
printf("Maximum = %d\n", max);
return 0;
}
8. Special Operators
Definition: Includes sizeof, address (&), pointer (*), and structure (->) operators.
Example Program using sizeof
and &
:
#include <stdio.h>
int main() {
int a = 100;
printf("Size of a = %lu\n", sizeof(a));
printf("Address of a = %p\n", &a);
return 0;
}
16. Explain the Syntax of Switch statement with example.
The switch statement in C allows multi-way branching by evaluating an expression and executing the corresponding case block.
Syntax:
switch (expression)
{
case constant1:
// Code for constant1
break;
case constant2:
// Code for constant2
break;
default:
// Code if no case matches
}
Example:
#include <stdio.h>
int main()
{
int day = 3;
switch (day)
{
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednesday\n");
break;
default:
printf("Invalid day\n");
}
return 0;
}
Output: Wednesday
21. Write a program to find the trace of a matrix.
#include <stdio.h>
int main()
{
int matrix[10][10], i, j, n, trace = 0;
printf("Enter the size of square matrix (n x n): ");
scanf("%d", &n);
printf("Enter the elements of the matrix:\n");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &matrix[i][j]);
}
// Calculating trace
for (i = 0; i < n; i++)
{
trace += matrix[i][i]; // sum of diagonal elements
}
printf("Trace of the matrix = %d\n", trace);
return 0;
}
Input:
Enter the size of square matrix: 3
Enter the elements:
1 2 3
4 5 6
7 8 9
Output: Trace of the matrix = 15
22. Explain the various categories of user defined functions.
A user-defined function is a custom function written by the programmer to perform a specific task. Functions help in dividing a large program into smaller modules, making it easy to understand, test, and reuse.
1. Functions with No Arguments and No Return Value
No input parameters
Doesn’t return any value
Used for simple tasks like printing messages.
Example:
#include <stdio.h> // Function declaration void greet(); int main() { greet(); // Function call return 0; } // Function definition void greet() { printf("Hello, World!\n"); }
Output:
Hello, World!
2. Functions with Arguments but No Return Value
Takes input parameters
Performs operations but doesn’t return a value
Used for calculations where the result is printed inside the function.
Example:
#include <stdio.h> // Function declaration void add(int a, int b); int main() { int x = 5, y = 3; add(x, y); // Function call with arguments return 0; } // Function definition void add(int a, int b) { printf("Sum: %d\n", a + b); }
Output:
Sum: 8
3. Functions with Arguments and Return Value
Takes input parameters
Returns a computed value
Most commonly used for reusable calculations.
Example:
#include <stdio.h> // Function declaration int multiply(int a, int b); int main() { int x = 4, y = 5; int result = multiply(x, y); // Function call printf("Product: %d\n", result); return 0; } // Function definition int multiply(int a, int b) { return a * b; }
Output:
Product: 20
4. Functions with No Arguments but Return a Value
No input parameters
Returns a value
Often used for getting user input or generating values.
Example:
#include <stdio.h> // Function declaration int getNumber(); int main() { int num = getNumber(); // Function call printf("You entered: %d\n", num); return 0; } // Function definition int getNumber() { int n; printf("Enter a number: "); scanf("%d", &n); return n; }
Output:
Enter a number: 7 You entered: 7
5. Recursive Functions
Calls itself until a base condition is met
Used for problems that can be broken into smaller sub-problems
Examples: Factorial, Fibonacci series.
Example (Factorial Calculation):
#include <stdio.h> // Function declaration int factorial(int n); int main() { int num = 5; printf("Factorial of %d: %d\n", num, factorial(num)); return 0; } // Function definition int factorial(int n) { if (n == 0 || n == 1) return 1; else return n * factorial(n - 1); // Recursive call }
Output:
Factorial of 5: 120