0% found this document useful (0 votes)
44 views33 pages

Programming in C and Python Exam Guide

The document outlines the structure and content of the Term-End Examination for the Programming in C and Python course (MCS-201) for the Post Graduate Diploma in Computer Applications. It includes various programming tasks and theoretical questions related to C and Python, covering topics such as error types, data structures, file handling, and functions. The examination is designed to assess students' understanding and practical skills in programming with a maximum score of 100 marks.

Uploaded by

adityagupta0405
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)
44 views33 pages

Programming in C and Python Exam Guide

The document outlines the structure and content of the Term-End Examination for the Programming in C and Python course (MCS-201) for the Post Graduate Diploma in Computer Applications. It includes various programming tasks and theoretical questions related to C and Python, covering topics such as error types, data structures, file handling, and functions. The examination is designed to assess students' understanding and practical skills in programming with a maximum score of 100 marks.

Uploaded by

adityagupta0405
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

No.

of Printed Pages : 4 MCS–201


POST GRADUATE DIPLOMA IN
COMPUTER APPLICATIONS
(PGDCA—NEW)
Term-End Examination
December, 2024
MCS–201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks : 100

Weightage : 70%

Note : Question No. 1 is compulsory. Attempt any


three questions from the rest.

1. (a) Describe Logical errors and Runtime


errors, with suitable example code in C, for
each. 5

(b) Write a program in C to find the length


of a string, without using strlen( )
function. Support your code with suitable
comments. 5

A–29/MCS–201 P. T. O.
[2] MCS–201

(c) Illustrate the concept of “Call by


Reference” with suitable code in C. Also
give one advantage and one disadvantage
of “Call by Reference.” 5
(d) Differentiate between Structure and Union
in C. Give suitable example code segment
for each. 5
(e) Write a program in Python to swap two
numbers entered by the user, without
using temporary variable. Support your
code with suitable comments. 5
(f) Explain Lambda functions, with the help of
a suitable code in Python. 5
(g) What is operator overloading ? How is it
achieved in Python ? Discuss with the help
of a suitable example. 5
(h) Briefly discuss the concept of Decorators in
Python. Also discuss the utility of
Decorators with suitable code in Python. 5

2. (a) Draw flow chart to find maximum of the


three numbers entered by the user. Also,
write algorithm for the same. Transform
your algorithm into a suitable code in C.
Support your code with suitable comments.

10

A–29/MCS–201
[3] MCS–201

(b) Write steps and Python code to create a


package named ‘Area’ and create 3
modules in this package i.e. ‘Area.’ The
modules may be named as square, circle
and rectangle, each having a function to
calculate area of square, circle and
rectangle respectively. Import the module
in separate location and use the functions.
10

3. (a) Differentiate between the following (Give


suitable code in C for each) :

(i) Break and Continue 5

(ii) While and do—while loops 5

(b) Write program in Python to perform the


following :

(i) Find sum of all odd and even numbers


upto a number specified by the user. 5

(ii) Check if a given year is a leap year or


not ? 5

4. (a) Write a program in C to copy the content of


one file to another file. Support your
program with suitable comments. 10

A–29/MCS–201 P. T. O.
[4] MCS–201

(b) Briefly discuss the interrelation between


Framework, Library, Package and Module
in Python. Give suitable example for each.
10

5. Differentiate between the following : 4×5=20

(i) Co-routines and Subroutines

(ii) Mutable and Immutable data types

(iii) Random Access and Sequential Access of


files

(iv) Overloading and Overriding

×××××××

A–29/MCS–201
No. of Printed Pages : 7 MCS–201

POST GRADUATE DIPLOMA IN

COMPUTER APPLICATIONS

(PGDCA–NEW)

Term-End Examination

June, 2025

MCS-201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks : 100

Weightage : 70%

Note : Question No. 1 is compulsory. Attempt

any three questions from the rest.

1. (a) Describe syntax errors and semantic

errors, with suitable example code in C

for each. 5

A–39/MCS–201 P. T. O.
[2] MCS–201

(b) Write a program in C to concatenate

two strings without using strcat( )

function. Support your code with

suitable comments. 5

(c) Illustrate the concept of “call by value”

with suitable code in C. Also give one

advantage and one disadvantage of call

by value. 5

(d) Compare recursion with iteration. Write

recursive code in C to find sum of 0 to n

where ‘n’ is an integer. 5

(e) Differentiate between package and

module in Python. Give an example for

each. 5

(f) What are immutable objects in Python ?

How do they differ from the mutable


A–39/MCS–201
[3] MCS–201

objects ? List the data types under each

category (i.e. mutable and immutable). 5

(g) Differentiate between the concept of

method overloading and method

overriding in Python. Give suitable

example for each. 5

(h) What are the co-routines in Python ?

How do they differ from subroutines ? 5

2. (a) Draw a flowchart to find factorial of a

number, entered by the user. Also,

write algorithm for the same.

Transform your algorithm into a

suitable code in C. Support your code

with suitable comments. 10

A–39/MCS–201 P. T. O.
[4] MCS–201

(b) Write Python code to perform the

following tasks :

(i) Create a database “Emp_DB”. 5

(ii) Create a table “Employee” in

database Emp_DB with columns

First_Name, Last_Name, Age,

Income. Support your code with

suitable comments. 5

3. (a) Briefly discuss the utility of the

following in C programming. Give

example code for each : 10

(i) Enumerated data types

(ii) Typedef

(iii) Typecasting

(iv) Sizeof operation

A–39/MCS–201
[5] MCS–201

(b) Write program in Python to perform the

following :

(i) Display the Fibonacci sequence

upto nth term provided by user. 5

(ii) To check whether a number

entered by the user is prime or not.

4. (a) Write Python code to perform the

following tasks : 10

(i) Create a file and add contents to it.

(ii) Copying a file to another file.

(iii) Deleting a file.

(iv) To display size of file in bytes.

(v) To display first n lines from a file,

where n is given by user.

A–39/MCS–201 P. T. O.
[6] MCS–201

(b) Briefly discuss the utility of the

following Built-in string functions : 10

(i) strstr

(ii) strupr

(iii) strncat

(iv) strchr

(v) strset

(vi) strncmp

(vii) strncpy

(viii)strspn

(ix) strrev

(x) strlwr

5. Write short notes on any five of the

following : 5×4=20

(i) Lambda functions

A–39/MCS–201
[7] MCS–201

(ii) Decorators

(iii) Iterators

(iv) Generators

(v) Map function

(vi) Unbuffered I/O

(vii) Array of pointers

×××××

A–39/MCS–201 P. T. O.
No. of Printed Pages : 4 MCS-201

POST GRADUATE DIPOLOMA IN


COMPUTER APPLICATIONS
(PGDCA) (NEW)
Term-End Examination
December, 2022
MCS-201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks :100

Weightage : 70%

Note : Question No. 1 is compulsory. Attempt any


three questions from the rest.

1. (a) Draw flowchart and write algorithm to


print Fibonacci series upto the number of
terms entered by the user. 5

(b) Differentiate between the structure and


union construct in C. Write suitable code
for each. 5

(c) Compare the term typedef and typecast in


C. Give suitable code for each. Also discuss
utility of both. 5

P. T. O.
[2] MCS-201

(d) Write a program in C to verify that the


string entered by the user is palindrome or
not. Support your program with suitable
comments. 5
(e) What is Jython ? How does Jython work ?
Compare module and package in context of
Python. 5
(f) What are generators in Python ? Compare
generators and lists. Also discuss utility of
generators in Python. 5
(g) What are iterators in Python ? How do
iterators differ from iterables ? Give
example of each. 5
(h) What are co-routines ? How do co-routines
support cooperative multitasking in
Python ? 5

2. (a) Write an algorithm to find the slope of a


line segment whose end point coordinates
are (x 1 , y 1 ) and (x 2 , y 2 ). The algorithm
gives output whether the slope is positive,
negative or zero. Transform your algorithm
into C program. 10
Note : Slope of line segment = (y 2 – y 1 )/
(x 2 – x 1 ).
[3] MCS-201

(b) What are Pandas ? Write steps to import,


read and print a CSV file using Pandas.
Also, transform your steps in to suitable
code in Python. 10

3. (a) Write short notes on the following : 10


(i) Looping constructs and its types in C
(ii) Functions and its types in C
Give suitable example for each.
(b) Discuss the connect( ) method of MySQL.
Connector interface. List the arguments
involved with connect( ) method. Write
Python code to create database
student_DB and to connect to student_DB
(make suitable assumptions wherever
necessary). 10

4. (a) Write a program in C to calculate the


product of two matrices. Support your code
with suitable comments. 10
(b) What are lists ? How do lists differ from
arrays ? What do you understand by the
term “Lists are mutable but tuples are
immutable” ? Write syntax for creation of
list and accessing the last element of the
list. 10

P. T. O.
[4] MCS-201

5. (a) Briefly discuss the concept of “Call by


value” and “Call by reference”. Give
example code in C for each. Support your
code with suitable comments. 10

(b) Write Python code to perform the


following : 10

(i) Copy a file [Link] to [Link]

(ii) Reading a file

(iii) Writing to a file

(iv) Appending content to a file

MCS–201
No. of Printed Pages : 4 MCS–201

POST GRADUATE DIPLOMA IN


COMPUTER APPLICATIONS
(PGDCA-NEW)

Term-End Examination
December, 2023
MCS–201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks :100

Weightage : 70%

Note : Question No. 1 is compulsory. Attempt any


three questions from the rest.

1. (a) Draw flow chart and write algorithm to


print Fibonacci series upto the number of
terms entered by the user. 5

(b) Write recursive and iterative program in C,


to find factorial of a number entered by the
user. 6

P. T. O.
[2] MCS–201

(c) Compare Break and Continue statement,


illustrate the use of both statements
through a suitable code in python. 6
(d) How do Mutable data types differ from
Immutable data types ? Briefly discuss the
syntax and utility of the following data
types in python : 5
(i) Lists
(ii) Tuples
(iii) Dictionaries
(e) Explain the concept of call by reference,
with suitable code in C. Compare it with
call by value mechanism. 6
(f) Compare the terms Typedef and Typecast
in C. Give suitable code for each. Also
discuss utility of both. 6
(g) What are Co-routines ? Explain, how
the co-routines support cooperative
multitasking in Python. 6

2. (a) Differentiate between Structure and Union


constructs in C. Write suitable code for
each. 7
(b) Differentiate between syntax error and
semantic error. Give example for each. 5
[3] MCS–201

(c) Discuss the following terms in context of


python. (Give example for each) : 8
(i) Framework
(ii) Library
(iii) Package
(iv) Module
Also, give relation between them.

3. (a) Discuss the relation between arrays and


pointers. Give suitable example in support
of your discussion. 5
(b) What is Jython ? How does Jython work ?
5
(c) Compare Global variables with Local
variables. Give suitable example for each. 5
(d) What are iterators ? How do iterators differ
from iterables ? Give example for each. 5

4. (a) Compare Buffered I/O with Unbuffered I/O


in C. 5
(b) Write a program in C to generate the
following pattern : 5
*
* *
* * *
* * * *

P. T. O.
[4] MCS–201

(c) Discuss the function of connect( ) method of


MySQL. Connection interface in Python.
List the arguments involved in the
connect( ) method. Write a python code to
create database Employee_DB and prepare
connection to Employee_DB. (Make
suitable assumptions whereever
necessary). 10

5. (a) What are Generators in Python ? Compare


Generators and Lists. Also, discuss the
utility of Generators in Python. 5
(b) In C, how && operator differs from &
operator ? Support your comparison with
suitable code in C. 5
(c) Write short notes on the following (give
utility of each) : 10
(i) Storage classes in C
(ii) Decorators in Python
(iii) Cursor objects
(iv) Functions and its types

MCS–201
No. of Printed Pages : 6 MCS–201

POST GRADUATE DIPLOMA IN

COMPUTER APPLICATIONS

(PGDCA–NEW)

Term-End Examination

June, 2024

MCS-201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks :100

Weightage : 70%

Note : Question No. 1 is compulsory. Attempt any

three questions from the rest.

1. (a) Draw flowchart and write algorithm to

print factorial of a number entered by the

user. 5

P. T. O.
[2] MCS–201

(b) Write recursive and iterative code in C, to

find sum of numbers from zero to n, where

n is the number entered by the user. 6

(c) What are lambda functions ? Discuss the

utility of lambda functions. Write lambda

function in Python to calculate cube of a

number, entered by the user. 6

(d) What is overloading and overriding in

Python ? Give suitable example code for

each. 5

(e) Explain the concept of call by value, with

suitable code in C. Give advantage and

disadvantage of call by value. 6

(f) Briefly discuss the syntax and

functionality of map( ) function in Python.

Write a program in Python to print the

square of the numbers present in the list,

using map( ) function. 6


[3] MCS–201

(g) Write a program in C to determine simple

interest and compound interest. Make

suitable assumptions and support your

code with suitable comments. 6

2. (a) What are storage classes ? How do storage

classes differ from data types in C ?

Discuss all four types of storage classes. 8

(b) Differentiate between static variable and

dynamic variable. Give suitable example

for each. 4

(c) In context of Python, differentiate the

following : 8

(i) Co-routines and Subroutines

(ii) Co-routines and Threads

3. (a) Differentiate between Random access and

Sequential access of files in C. Discuss the

P. T. O.
[4] MCS–201

syntax and role of fseek( ) and rewind( )

function, while accessing any file

randomly. 7

(b) Write Python code to perform the

following : 7

(i) Reading data from a file

(ii) Creating file and add content to it

(c) Write syntax for various looping controls.

Also draw flowchart of each, to exhibit

their respective execution of statements. 6

4. (a) Write a program in C to copy the content of

one text file to another text file. Support

your program with suitable comments. 6

(b) Write a program in C to verify that the

string entered by the user is a palindrome

or not. Support your program with suitable

comments. 4
[5] MCS–201

(c) Write Python code to perform the

following : 10

(i) Copy content of file [Link] to

[Link]

(ii) Reading a file

(iii) Writing a file

(iv) Appending a file

5. (a) What is a package in Python ? How does it

relate to module, library and framework ?

Write the steps to create a package in

Python. Also, illustrate the application of

these steps with suitable example code in

Python. 8

(b) Write an algorithm to find the slope of a

line segment whose input comprises of the

end point coordinates i. e.  x1 , y1  and

P. T. O.
[6] MCS–201

 x2 , y2  , and output comprises of the slope


of line (which may be positive, negative or

zero). Transform your algorithm into C

program. Support your code with suitable

comments. 8

{Note : Slope of line segment

( y2  y1 ) 
 .
( x2  x1 ) 

(c) Compare C and Python, as programming

languages. 4

MCS–201
[2] MCS-201

(c) How does syntax error differ from semantic


No. of Printed Pages : 4 MCS-201
error ? Give suitable example for each. 5

POST GRADUATE DIPOLOMA IN (d) Explain the concept of call by reference,


COMPUTER APPLICATIONS with suitable code in C. Give advantage

(PGDCA-NEW) and disadvantage of call by reference. 5

Term-End Examination (e) What is C-Python ? Briefly discuss the

December, 2021 relation between framework, library,


package and module in Python. 5
MCS-201 : PROGRAMMING IN C AND PYTHON

Time : 3 Hours Maximum Marks :100 (f) Differentiate between mutable and
immutable data types in Python. Briefly
Weightage : 70%
discuss the following data types of
Note : Question No. 1 is compulsory. Attempt any Python : 5
three questions from the rest.
(i) Lists

1. (a) Differentiate between Recursion and


(ii) Tuples
Iteration. Give suitable code in C for each.
(iii) Dictionaries
5
(g) What does map( ) function do ? Write a
(b) Compare flowchart and algorithm. Draw
program in Python to print the square of
flowchart to find factorial of a number the numbers present in the list, by using
entered by user. 5 map( ) function. 5

P. T. O.
[3] MCS-201 [4] MCS-201

(h) Compare overloading and overriding in 4. (a) Differentiate between Random access and
Python. Give suitable example code for Sequential access of files in C. Discuss the
each. 5 syntax and role of fseek( ) and rewind( )
function, while accessing any file. 10
2. (a) What are different data types in C ?
(b) What are Cursor Objects ? Briefly discuss
Explain use of these data types with the
the utility of cursor objects. Write Python
help of a C program. 10
code for a cursor to execute the SQL query,
(b) Write Python code to perform the
to print the version of database. Support
following : 10
your program with suitable comments. 10
(i) Reading data from a file
5. (a) Compare any two of the following (give
(ii) Creating a file and add content to it suitable C code for each) : 10

Support your code with suitable comments. (i) Buffered I/O and Unbuffered I/O

(ii) Break and Continue Statement


3. (a) List various looping control statements.
Write syntax of each statement. Also draw (iii) Structure and Union

flowchart for each statement. 10 (b) Differentiate between the following with
the help of suitable example for each : 10
(b) What are Lambda functions ? How do
(i) Co-routines and subroutines
Lambda functions differ from Built-in
functions ? Write lambda function to (ii) Co-routines and threads

calculate cube of a number. Also write the


program to find cube of a number without
using lambda function. 10 MCS–201

P. T. O.
No. of Printed Pages : 4 MCS-201

POST GRADUATE DIPLOMA IN COMPUTER


APPLICATIONS (NEW)
(PGDCA (NEW))

Term-End Examination

June, 2022

MCS-201 : PROGRAMMING IN C AND PYTHON

Time : 3 hours Maximum Marks : 100


(Weightage : 70%)

Note : Question number 1 is compulsory. Attempt any


three questions from the rest.

1. (a) Compare flowchart and algorithm. Draw a


flowchart to find the factorial of a number
entered by a user. 5

(b) Write a program in C to print all ASCII codes.


Support your program with suitable
comments for better readability. 5

MCS-201 1 P.T.O.
(c) Discuss the terms Typedef and Typecast
in C, with the help of a suitable example of
each. Analyse the code given below and
give its output : 5
main()
{
int a, b = 5;
float f;
a = 5/2;
f = (float) b/2.0;
(a < f) ? b = 1 : b = 0;
printf("b = %d", b);
}

(d) Explain the concept Call by Reference.


Give a suitable code in C to support your
explanation. Also give the advantage of
Call by Reference over Call by Value
concept. 5

(e) What is Jython ? How does Jython work ?


Compare module and package in the
context of Python. 5

(f) What are tuples in Python ? What do you


understand by the term ‘‘tuples are
immutable’’ ? Write Python syntax for
creation, printing and accessing specific
element of the tuple. 5

MCS-201 2
(g) What does map( ) function do ? Write a
program in Python to print the cube of the
numbers present in the list, by using
map( ) function. 5

(h) What are Generators in Python ? Compare


Generators and Lists. Also discuss the
utility of Generators in Python. 5

2. (a) What is [Link] ? Briefly discuss


the methods used by [Link] to
establish connection and retrieve records
from the database. 10

(b) Write steps to create a package. Apply


these steps to create a package named
volume and create 3 modules in it named
cube, cuboid and sphere, having function to
calculate volume of the cube, cuboid and
sphere respectively. Import the modules
defined in the package and use the defined
functions for calculation of volume
respectively. 10

3. (a) Write Python codes to perform the


following : 10
(i) Reading data from a file.
(ii) Creating a file and adding contents to
it.

(b) Write an algorithm to print the Fibonacci


series. Transform your algorithm into
Python code, ‘‘To print the Fibonacci series
up to n terms, entered by the user’’. 10

MCS-201 3 P.T.O.
4. (a) Compare Sequential and Random access of
files in C. Briefly discuss the syntax and
role of fseek( ) and rewind( ) function, while
accessing a file randomly. 10

(b) Write an algorithm to find the HCF


(Highest Common Factor) of the two
numbers entered by a user. Transform
your algorithm into a C program, support
your program with suitable comments. 10

5. (a) Briefly discuss the relation between


pointers and arrays, giving suitable
example. Write a program in C, to print
transpose of a 2D matrix entered by a user.
Also give comments. 10
(b) Write the syntax of looping control
statements. Also draw the flowchart for
each statement. Write a program in C to
generate the following pattern : 10
1
1 2
1 2 3

MCS-201 4

Common questions

Powered by AI

Decorators modify or extend function behavior without permanently modifying them. Example: @decorateFunc modifications function output. They support clean coding and separation of concerns by centralizing code across function operations, such as logging, validation, or function measurement .

Syntax errors arise from violating language rules, such as missing semicolons. Example: int x = ; causes a syntax error. Semantic errors occur from improper logic or generally valid code that doesn't function as expected, such as incorrect results from valid expressions, like using subtraction instead of addition .

Logical errors occur when the program compiles successfully but behaves unexpectedly due to incorrect logic. For instance, if calculating a sum as subtraction: int sum = a - b;. Runtime errors occur during program execution, such as division by zero or accessing invalid memory. Example: int result = a / 0; causes a runtime error .

Modules are single Python files containing related functions/classes, loaded with 'import module'. Packages are directories containing modules and an '__init__.py' file, enabling hierarchical module management, e.g., a 'math' package with submodules for algebra. They enhance modular programming through structured and reusable code .

Mutable objects can be altered; common examples are lists and dictionaries. Immutable objects can't be changed after creation, examples being tuples and strings. This impacts performance and method implementation, affecting storage and data integrity with applications like config settings vs dynamic data .

Coroutines are used for asynchronous programming, allowing suspension and resumption at key points, facilitating complex operations like I/O tasks without blocking. Subroutines are traditional functions called and returned systematically. Coroutines multitask by yielding control during sleep or waiting, contributing to non-blocking applications .

Call by reference in C allows functions to modify the actual arguments by passing memory addresses. Example: void swap(int *x, int *y) swaps the values of two integers. One advantage is modifying variables without returning values. A disadvantage is potential unintended side effects if memory is mismanaged .

Method overloading allows the same method name with different parameters, though Python doesn't directly support it, achievable with default parameters. Example: def add(x, y=0). Method overriding involves redefining methods in subclasses, replacing parent class logic. Example: class Child(Parent): def method(). Overriding promotes polymorphism, overloading encourages method flexibility .

A Lambda is an anonymous function expressed as: lambda x: x**2. It can be used to create small one-time functions, reducing code length and introducing flexibility. They're often used with functions like 'filter' and 'map'. This makes lambdas useful for quick functional programming tasks without formally defining functions .

Structures store different data types in separate memory locations. Example: struct anStruct {int a; float b;};, allowing simultaneous access to 'a' and 'b'. Unions store different types in a shared memory location, thus can only store one value at a time. Example: union anUnion {int a; float b;};, compromising memory for versatility .

You might also like