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

Scheme for C Programmingnew

This document is an examination paper for the Fourth Semester B.Sc Electronics course, focusing on Programming in C. It includes questions on various topics such as data types, control statements, functions, arrays, and pointers, with sections for short answers and detailed explanations. The exam is structured into three parts, with varying marks assigned to each question.

Uploaded by

Sajmal Sajmal
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 views5 pages

Scheme for C Programmingnew

This document is an examination paper for the Fourth Semester B.Sc Electronics course, focusing on Programming in C. It includes questions on various topics such as data types, control statements, functions, arrays, and pointers, with sections for short answers and detailed explanations. The exam is structured into three parts, with varying marks assigned to each question.

Uploaded by

Sajmal Sajmal
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/ 5

QP CODE: B.

Sc DEGREE (CBCS) EXAMINATION, October 2021

Fourth Semester B.Sc Electronics Model III

Core Course - EL4CRT10 - PROGRAMMING IN C

2017 Admission onwards

9A0A89DC
Time: 3 Hours Max. Marks : 80

Part A .Answer any ten questions. Each question carries 2 marks.

1.List the rules for creating identifiers

A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
The first letter of an identifier should be either a letter or an underscore.
Can not use keywords like int, while etc. as identifiers. 2 marks

2.What are data types

Fundamental Data Type int, char, float, double

Derived Data Type array, pointer, structure, union

Enumeration Data Type enum

Void Data Type void 2 marks

3. Explain nesting of if else statement

An if statement can be followed by an optional else if...else statement, which is very useful to test various
conditions using single if...else if statement. 2 marks

4. Explain the basic difference between while and do while statement

Give marks for any two difference 2 marks

While loop checks the condition first and then executes the statement(s), whereas do
while loop will execute the statement(s) at least once, then the condition is checked.
While loop is entry controlled loop whereas do while is exit controlled loop.
In the while loop, we do not need to add a semicolon at the end of a while condition but
we need to add a semicolon at the end of the while condition in the do while loop.
While loop statement(s) is executed zero times if the condition is false whereas do while
statement is executed at least once.
While loop allows initialization of counter variable before starting the body of a loop
whereas do while loop allows initialization of counter variable before and after starting the body of a loop.

5. Explain the use of continue statement with the help of an example. 2 marks

The continue statement is used inside loops. When a continue statement is encountered inside a loop, control jumps
to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the
current iteration.
6. What is an array? How does it differ from ordinary variable?

An ordinary variable can hold only one value whereas an array variable can refer to a group of values of the same
data type by using a subscript. 2 marks

7. What are the advantages of using function in a program?

Give marks for two advantages 2 marks

Avoid repetition of codes.


Increases program readability.
Divide a complex problem into simpler ones.
Reduces chances of error.
Modifying a program becomes easier by using function.
8.State the rules for initializing the structure 2 marks

Give marks for the rules for initializing the structure

9. What is a Union in C programming


A union is a special data type available in C that allows to store different data types in the same memory location

2 marks.

10.What are the advantages of using pointers

The pointers are variables that store the address of another variable. And every variable has a unique address in
memory

Less time in program execution


Working on the original variable
With the help of pointers, we can create data structures (linked-list, stack, queue).
Returning more than one values from functions
Searching and sorting large data very easily
Dynamically memory allocation
2 marks

11.What are typedef statements.

The typedef is an advance feature in C language which allows us to create an alias or new name for an existing
type or user defined type. 2 marks

12.Explain realloc() function

In the C Programming Language, the realloc function is used to resize a block of memory that was previously
allocated. The realloc function allocates a block of memory (which be can make it larger or smaller in size than the
original) and copies the contents of the old block to the new block of memory, if necessary. 2 marks

Part B Answer any six questions. Each question carries 5 marks.

13. Draw the flowchart to check the given no is palindrome or not.

Give marks for flowchart /algorithm/ program

14. Explaination of the precedence of operators. 5 marks

Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated
and explanation . 3marks
Example 2marks

15. Explain the working of switch

Switch statement in C tests the value of a variable and compares it with multiple cases. Once the case match is
found, a block of statements associated with that particular case is executed. Each case in a block of a switch has a
different name/number which is referred to as an identifier. The value provided by the user is compared with all the
cases inside the switch block until the match is found. 3 marks

Format of while loop 2marks

16. Explain the use of for loop with example

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific
number of times. 3 marks
The syntax of a for loop in C programming language is −
for ( init; condition; increment )
{
statement(s); 2 marks
}
17. Declaration and initialization of two dimensional array 5 marks

The two-dimensional array can be defined as an array of arrays. The 2D array is organized as matrices which can be
represented as the collection of rows and columns. However, 2D arrays are created to implement a relational
database lookalike data structure. It provides ease of holding the bulk of data at once which can be passed to any
number of functions wherever required. 3marks

Example 2marks

18. Syntax of function 5 marks

o Function declaration A function must be declared globally in a c program to tell the compiler
about the function name, function parameters, and return type.
o Function call Function can be called from anywhere in the program. The parameter list must not
differ in function calling and function declaration. We must pass the same number of functions as it is
declared in the function declaration.
o Function definition It contains the actual statements which are to be executed. It is the most
important aspect to which the control comes when the function is called. Here, we must notice that only
one value can be returned from the function.

Eg

19. Differentiate between array and structure variable 5 marks

Explanation of Array and structure with examples

20. Explain the usage of pointer to structure variables 5 marks

Give marks for any explanation of pointers and structure .

21.Different preprocessor directives in C

Give marks for any 5 preprocessor directives . 5 marks

#define
Substitutes a preprocessor macro

#include
Inserts a particular header from another file.

#ifdef
Returns true if this macro is defined

#ifndef
Returns true if this macro is not defined

#if
Tests if a compile time condition is true.

#endif
Ends preprocessor conditional.

#error
Prints error message on stderr.

Part C Answer any two questions. Each question carries 15 marks.

22. Draw the flow chart for finding the roots 15 marks

Give marks for flow chart/program/algorithm for finding the roots.

23 Give marks for program which checks given no is print prime number/program which prints prime no series

15 marks
24. String handling functions

Give marks for any 5 functions

strcpy() strcpy(string1, string2) Copies string2 value into string1

strlen() strlen(string1) returns total number of characters in string1

strcat() strcat(string1,string2) Appends string2 to string1

strcmp() strcmp(string1, string2) Returns 0 if string1 and string2 are the same;
less than 0 if string1<string2; greater than 0 if string1>string2

strlwr() strlwr(string1) Converts all the characters of string1 to


lower case.

25. Call by value and call by reference with example

Call by value in C

o In call by value method, the value of the actual parameters is copied into the formal parameters. In
other words, we can say that the value of the variable is used in the function call in the call by value
method.
o In call by value method, we can not modify the value of the actual parameter by the formal
parameter.
o In call by value, different memory is allocated for actual and formal parameters since the value of
the actual parameter is copied into the formal parameter.
o The actual parameter is the argument which is used in the function call whereas formal parameter
is the argument which is used in the function definition. 3.5marks

Call by reference in C

o In call by reference, the address of the variable is passed into the function call as the actual
parameter.
o The value of the actual parameters can be modified by changing the formal parameters since the
address of the actual parameters is passed.
o In call by reference, the memory allocation is similar for both formal parameters and actual
parameters. All the operations in the function are performed on the value stored at the address of the actual
parameters, and the modified value gets stored at the same address. 3.5 marks

Example 8 marks

You might also like