0% found this document useful (0 votes)
4 views4 pages

C (Commerce)

The document is an examination paper for a B.Sc degree in Computer Science, focusing on Problem Solving using C. It includes short answer questions, short essay questions, and an essay question covering various topics such as keywords, variables, operators, loops, functions, and arrays in C programming. The exam is structured to assess students' understanding of fundamental concepts in C programming and their ability to apply these concepts in problem-solving.

Uploaded by

Nisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

C (Commerce)

The document is an examination paper for a B.Sc degree in Computer Science, focusing on Problem Solving using C. It includes short answer questions, short essay questions, and an essay question covering various topics such as keywords, variables, operators, loops, functions, and arrays in C programming. The exam is structured to assess students' understanding of fundamental concepts in C programming and their ability to apply these concepts in problem-solving.

Uploaded by

Nisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

//' q4c2/

TIIIRD SERESTER B.Sc DEGREE EXAENATI0N


(CBCSS - UG)
Computer Science
CSC3C03-PROBLEM SOLVING USING C
(2019Admissions)

Time: 2 Hours Maximum: 60 Marks


Section A - Short Answer type questions
(Answer all questions, each correct answer carries a maximum of 2 marks. Ceiling 20 marks)

1. Der]ne keyword.
Keywords are predefined, reserved words in C and each of which is associated with specific features.
These words help us to use the functionality of c language. They have special meaning to the
compilers. Ex: if, else, break etc.
2. Derlne variable.
A variable is the name of a memory location. It is used to store some data. Its value can be changed and
can be reused many times. Ex: sum, total etc.

3. Which are the different logical operators in C?

Logical Operators are used to connect different relational expressions. Logical operators in C are:

Logical AND operator (&&), Logical OR (||), Logical NOT(!)

4. What is associativity of operators?


Associativity is used when there are two or more operators of sane precedence are present in an
expression and it is evaluated in the order either from left to right or right to left. (Provide example
also)
5. What is putso and getso ?
getso is a function that reads a string from standard input while puts() is a function that prints a string
to the standard output. (give example or syntilx)
6. What is a decision-making statement?
Decision making statements in programming languages decides the direction of flow of program
execution. Decision making statements are used to check whether a paticular condition has occuned
or not and then direct the computer to execute certain instructions accordingly.

7. Write the syntax of (whi]e' loop.


The syntax of the loop is:
while (test condition)
(
// statements inside the body of the loop
)
The while' lcop evaluates the test condition iliside the parenthesis ( ). If the test expression is true,

statements inside the body of while loop are executed. Then, the test expression is evaluated again.

The prcoess is repeated until the condition becomes false.

Page 1 of 4
8. What is a `goto' statement?
The goto statement is ajump statement which is sometimes also referred to as unconditional jump

9. What are library functions?


The library functions are built-in functions in C programming. These functions are defined in header files,

Ex: prindo, scanfo etc.

10. What is an automatic variable?


This is the default storage class for all the variables declared inside a function or a block. Auto varichles
can be only accessed within the block/function they have been declared and not outside them (which
defines their scope).
They are assigned a garbage value by default whenever they are declared.

11. What is dynamic memory a]]ocation?


The Dynamic memory allocation enables the C programmers to allocate memory at runtime. malloc 0 -
allcoates a blcok of memory in bytes at runtime. calloc 0 -allocating continuous blocks of memory at run
time. reallco 0 -used for reduce (or) extend the allocated memory. Freeo to release the allocated memory.
12. What are the advantages of functions?
By using functions, we can avoid rewriting sane logic/code again and again in a program.

We can cal-I C 'functions any mm.6er of tim.es in a program and from any place in a program.

We can track a large C program easily when it is divided into multiple functions.

Reusability is the main achievement of c functions.

The program will be easier to understand, maintain and debug.

(Specify any 4)

Section 8 -Short Essay type questions


(Answer all questions, each correct answer carries a maximum of 5 marks. Ceiling 30 marks)

13. Define token. Explain the different types of tokens in C.


In C programming, a token is the smallest unit in the source code that is recognized by the compiler. There are
six main`types of tokens in C:
Keywords: Reserved words that have special meanings in the C language (e.g., "int," "if," "while")
Identifiers: Userdefined nanes for variables, functions, or other entities (e.g., variable names like "x" or
"sum").
Constants: Fixed values that do not change during program execution, including integer constants (e.g., 5),
floating-point constants (e.g., 3.14), and character constants (e.g., 'A').
String Literals: Sequences of characters enclosed in double quotes (e.g., "Hello, World! ").
Operators: Symbols used for performing operations (e.g., "+," "-", "*", "&&").

Page 2 of 4
Punctuation: Symbols used for various purposes, such as semicolons, commas, and parentheses (e.g., ";", ",",
"(").

14. Write a note on the different I/0 functions in C.


C provides various input and output functions. Common I/0 functions include "printf' for output and "scanf'
for input. Oner functions like "fyrintf," "fscanf," "getc," and "putc" enable file-based input and output.
15. Write a note on the different looping statements in C.
C offers three primary looping statements:
for Loop: Used for iterating over a range of values with a specified start, end, and increment.
while Loop: Repeats a block of code as long as a given condition is true.
do-while Loop: Similar to the "while" loop but guarantees the code block is executed at least once before
checking the condition.
16. Explain about the different types of operators ill C.
Operators in C: C supports various types of operators, including arithmetic operators (+, -, *, /, °/o), relational
operators (±, !=, <, >, <=, >=), logical operators (&&, ||, !), assignment operators (=, +=, I, *=, /=), bitwise
operators (&, I, ^), and more.
17. Define structure. Explain the concept in detail.
A structure is a user-defined data type that allows you to group variables of different data types under a single
name. It is used to create complex data structures and is defined using the "struct" keyword. For example, you
can create a "Person" structure with members like name, age, and address.
18. Explain about the different foms of `if statement in C.
The "if" statement is used for conditional execution. In C, you can have different forms of the "if' statement,
including:
Simple 'if: Executes a block of code if a condition is true.
'if-else': Executes one block of code if the condition is true and another if it's false.
'if-else if{lse': Allows you to check multiple conditions in a sequence.
19. Explain the concept of pointers in C.

Section C -Essay type questions


(Answer any one question, correct answer canies 10 marks)

20. Prepare a note on the concept of arrays in C.


Arrays and Their Types in C:

Arrays are a fundanental data structure in C, used to store a collection of elements of the same data type
under a common name. They offer an efficient way to work with a large set of data, making it easier to access
and manipulate individual elements. In C, arrays come in various types and forms.

I . One-Dimensional Arrays:

Declaration: A one-dimensional array is declared by specifying its data type, followed by the array name and
the size enclosed in square brackets. For example, int nbmbers[5]; declares an integer array of size 5.
Access: Elements in a one-dimensional array are accessed using an index (subscript). The index starts at O`-for
the first element.
Initialization: You can initialize one-dimensional arrays at the time of declaration or later in the program.
2. Two-Dimensional Arrays:

Declaration: A twordimensional array is essentially a matrix with rows and columns. It is declared with two
sizes: one for rows and one for columns. For example, int matrix[3][4]; declares a 3x4 integer array.

Page 3 of 4
Access: Elements in a twordimensional array are accessed using two indices, one for the row and one for the
column. For example, matrix[1][2] accesses the element in the second row and third column.
Initialization: You can initialize twordimensional arrays similar to one-dimensional arrays.
3. Multidimensional Arrays:

In C, you can create arrays with more than two dimensions by extending the concept of two-dimensional
arrays.
21. Explain in detail about the concept of functions in C.
In C programming, functions are self-contained blocks of code that perform specific tasks or operations.
F_Lmctions mak_e it possible to modularize code, making it more organized and easier to maintain. Here's a
detailed explanation of functions in C:

I. Function Declaration and Definition:

A function is declared using a function prototype, specifying its return type, name, and any parameters it
accepts.
For example: int add(int a, int b); declares a function named "add" that takes two integer parameters and
returns an integer.

2. Function Parameters :

Functions can accept zero or more parameters. Parameters are variables that store values passed to the
function when it is called.
Parameters are defined in the function prototype and used within the function body.
For example: int add(int a, int b) defines two parameters, a and b.

3. Function Body:

The function body contains the actual code that defines what the function does.
It is enclosed within curly braces { } and contains statements to perform the desired task.
For example: return a + b; adds the two paranieters and I.etums the result.

4. Function Call:

To use a function, you need to call it within your program. A function call provides the necessary arguments
(values) for the parameters.
For example: int result = add(3, 5); calls the "add" function with arguments 3 and 5.

5. Return Statement:

Functions can return values using the return statement. The return type specified in the function prototype
indicates the type of value the function should return.
For example: return a + b; returns the sum of a and b.

6. Function Prototypes:

It's a good practice to declare the function prototype before the main function to let the compiler know about
the function's existence and signature.
This allows you to call the function before its definition in the program.

Page 4 of 4

You might also like