Download C Programming: Data Types, Arrays, Structures, Pointers, Functions, Algorithms and more Lecture notes Computer Science in PDF only on Docsity!
CSE DEPARTMENT, NCERC PAMPADY Page 1
NEHRU COLLEGE OF ENGINEERING AND RESEARCH CENTRE
(NAAC Accredited) (Approved by AICTE, Affiliated to APJ Abdul Kalam Technological University, Kerala)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
COURSE MATERIALS
CS100 COMPUTER PROGRAMMING
VISION OF THE INSTITUTION
To mould true citizens who are millennium leaders and catalysts of change through excellence in
education.
MISSION OF THE INSTITUTION
NCERC is committed to transform itself into a center of excellence in Learning and Research in Engineering and Frontier Technology and to impart quality education to mould technically competent citizens with moral integrity, social commitment and ethical values.
We intend to facilitate our students to assimilate the latest technological know-how and to imbibe discipline, culture and spiritually, and to mould them in to technological giants, dedicated research scientists and intellectual leaders of the country who can spread the beams of light and happiness among the poor and the underprivileged.
CSE DEPARTMENT, NCERC PAMPADY Page 2
ABOUT DEPARTMENT
Established in: 2002
Course offered : B.Tech in Computer Science and Engineering
M.Tech in Computer Science and Engineering
M.Tech in Cyber Security
Approved by AICTE New Delhi and Accredited by NAAC
Affiliated to the University of Dr. A P J Abdul Kalam Technological University.
DEPARTMENT VISION
Producing Highly Competent, Innovative and Ethical Computer Science and Engineering Professionals
to facilitate continuous technological advancement.
DEPARTMENT MISSION
- To Impart Quality Education by creative Teaching Learning Process
- To Promote cutting-edge Research and Development Process to solve real world problems with emerging technologies.
- To Inculcate Entrepreneurship Skills among Students.
- To cultivate Moral and Ethical Values in their Profession.
PROGRAMME EDUCATIONAL OBJECTIVES
PEO1: Graduates will be able to Work and Contribute in the domains of Computer Science and Engineering through lifelong learning. PEO2: Graduates will be able to Analyse, design and development of novel Software Packages, Web Services, System Tools and Components as per needs and specifications. PEO3: Graduates will be able to demonstrate their ability to adapt to a rapidly changing environment by learning and applying new technologies. PEO4: Graduates will be able to adopt ethical attitudes, exhibit effective communication skills, Teamworkand leadership qualities.
CSE DEPARTMENT, NCERC PAMPADY Page 4
PROGRAM SPECIFIC OUTCOMES (PSO)
PSO1 : Ability to Formulate and Simulate Innovative Ideas to provide software solutions for Real- time Problems and to investigate for its future scope.
PSO2 : Ability to learn and apply various methodologies for facilitating development of high quality System Software Tools and Efficient Web Design Models with a focus on performance optimization.
PSO3 : Ability to inculcate the Knowledge for developing Codes and integrating hardware/software products in the domains of Big Data Analytics, Web Applications and Mobile Apps to create innovative career path and for the socially relevant issues.
COURSE OUTCOMES
CO1 Describe fundamentals of C programming such as variables, methods, conditional and iterative execution. CO Analyze and solve programming problems using a procedural and algorithmic approach with functional decomposition CO Design programs that demonstrate effective use of advanced C features including pointers and memory management CO Develop and execute computerized solution for various problems in functions using appropriate C language constructs CO5 Identify sorting and searching techniques to solve^ application programs
CO Identify and Implement file operations for given application
MAPPING OF COURSE OUTCOMES WITH PROGRAM OUTCOMES
Note: H-Highly correlated=3, M-Medium correlated=2, L-Less correlated=
PO 1
PO 2
PO 3
PO 4
PO 5
PO 6
PO 7
PO 8
PO 9
PO 10
PO 11
PO 12
CO1 (^3 3 2 ) CO2 (^3 3 2 2 2 2 ) CO3 (^2 2 3 3 3 ) CO4 (^3 2 3 3 3 2 3 2 ) CO5 (^3 2 3 2 3 2 2 ) CO6 (^3 3 3 3 2 2 )
CSE DEPARTMENT, NCERC PAMPADY Page 5
MAPPING OF COURSE OUTCOMES WITH PROGRAM SPECIFIC OUTCOMES
Note: H-Highly correlated=3, M-Medium correlated=2, L-Less correlated=
PSO 1
PSO 2
PSO 3
CO1 (^3 ) CO2 (^3 ) CO3 (^3 3 ) CO4 (^3 ) CO5 (^3 ) CO6 (^3 )
QUESTION BANK
MODULE I
Q:NO: QUESTIONS CO KL PAGE NO:
1 Differentiate between Keywords and
Identifiers in C with examples.
CO1 K3 25
2 Describe about the fundamental data-types
in C.
CO1 K2 34
3 Write a C program to print the Fibonacci
series.
CO1 K 3 61
4 Explain with example, how break and
continue constructs are useful in C
programming.
CO1 K2 66
5 Explain the working of loop control
statements in C with examples.
CO1 K5 58
6 Write a C program to find the largest of
three numbers.
CO1 K3 44
7 Point out the different pre-processor
directives with its uses and example.
CO1 K4 20
4 Compare and Contrast C data structures
Structure and Union with example.
CO2 K4 82,
5 Write a C program to find the count of the
inputted character in a given string.
CO2 K3 75
6 Write a C program to sort names in an
array in lexicographical order.
CO2 K3 69
7 Write a C program to find the number of
vowels, consonants, digits and white space
in a string.
CO2 K3 75
8 Write a C program for matrix addition. CO2 K6 73
9 Distinguish between an array and a
structure with example.
CO2 K4 69,
10 Write a C program to copy a string without
built in function.
CO2 K3 75
11 Differentiate between Structure and Union
with example.
CO2 K4 82,
12 Write a C program to find the frequency of
character in a given string.
CO2 K3 75
13 Write a C program to find the largest and
smallest element in an integer array.
CO2 K3 69
14 Write a C program to print an array in
reverse order.
CO2 K3 69
MODULE III
1 Explain the concept of pointers with
declaration and initialization.
CO3 K2 103
2 Write a program to sort elements of an
array using pointers.
CO3 K6 111
3 Write a program to create an employee
structure and access its member variables
using pointers.
CO3 K6 122
4 Write a program to swap two numbers
using pointers.
CO3 K3 104
5 Write a program to create a structure with
name student and member variables name,
number and rank and then access the
structure members with pointers.
CO3 K6 123
6 Write a program to read a string and print
the string in the output terminal using
pointers.
CO3 K6 113
17 Point out the benefits of using pointers. CO3 K4 108
MODULE IV
1 Describe recursion with an example. CO4 K2 145
2 Justify the need of functions in C. CO4 K1 131
3 Write a C program to find factorial of a
given number using recursive function.
CO4 K3 145
4 Write a C program to swap numbers by: (a)
call by reference and (b) call by value.
CO4 K6 147
5 Write a C program to find the sum of
natural numbers using recursion.
CO4 K3 145
6 Write a C program to find the reverse of a
number using recursive function.
CO4 K6 145
7 Write a C program to find the sum of digits
of a number using recursive function.
CO4 K6 145
8 Explain how the memory allocation is
performed dynamically in C.
CO4 K2 102
9 Write a C program using function to check
whether a number is Armstrong or not.
CO4 K6 131
10 Write a C program to find the reverse of a
number using recursive function.
CO4 K6 145
11 Write a C program to find prime number or
not using recursion.
CO4 K3 145
12 With suitable example explain different
function parameter passing methods in C.
CO4 K2 147
13 Write a C program to check whether a
given number is perfect number or not
using function.
CO4 K3^145
14 Write a C program to find nCr using
function.
CO4 K3 145
15 Write a C program to simulate a menu
driven calculator with addition,
subtraction, multiplication, division and
exponentiation operations. Use a separate
function to implement each operation
CO4 K6 131
16 Write a C program to print Fibonacci series
using recursion.
CO4 K3 145
MODULE V
1 Explain the working of selection sort with
an example.
CO5 K5 166
1 Explain any Six File opening modes
available in C.
CO6 K 2 199
2 Write any two file handling functions used
to write data into text files.
CO6 K3 202
3 Write a C program to create a file and store
information about a person, in terms of his
name, age and salary.
CO6 K6 201
4 What is the purpose of fopen( ) and fclose(
) functions in C.
CO6 K1 209
5 What is the purpose of getw( ) and putw( )
function?
CO6 K1 199
6 Discuss the concept of binary file in C. CO6 K2 204
7 Write a C program to copy the content of a
given text file to a new file after replacing
every lowercase letters with corresponding
uppercase letters.
CO6 K6 207
8 Write a C program to write a set of
numbers to a file and separate the odd and
even numbers to two separate files.
CO6 K3 199
9 What is an unformatted data file? List the
applications of such files.
CO6 K1 204
10 Write a C program to copy the contents of
a text file to another file. Pass the filename
using command line arguments.
CO6 K6 201
11 Discuss about unformatted data files and
write on any two library functions
associated with this.
CO6 K2 204
12 With suitable example explain any four
different File I/O operations in C?
CO6 K5 198
MODULE 1
Overview of C Language
C is a structured programming language developed by Dennis Ritchie in 1973 at Bell
Laboratories. It is one of the most popular computer languages today because of its
structure, high-level abstraction, machine independent feature etc. C language was
developed to write the UNIX operating system, hence it is strongly associated with
UNIX, which is one of the most popular network operating system in use today.
Features of C language
It is a robust language with rich set of built-in functions and operators that can
be used to write any complex program.
The C compiler combines the capabilities of an assembly language with features
of a high-level language.
Programs Written in C are efficient and fast. This is due to its variety of data type
and powerful operators.
It is many time faster than BASIC.
C is highly portable this means that programs once written can be run on another
machines with little or no modification.
Another important feature of C program, is its ability to extend itself.
A C program is basically a collection of functions that are supported by C library.
We can also create our own function and add it to C library.
C language is the most widely used language in operating systems and embedded
system development today.
Different parts of C program
Pre-processor
Header file
Function
Variables
Statements & expressions
Comments
Pre-processor
#include is the first word of any C program. It is also known as a pre-processor.
The task of a pre-processor is to initialize the environment of the program, i.e to link
the program with the header files required.
So, when we say #include <stdio.h>, it is to inform the compiler to include
the stdio.h header file to the program before executing it.
Preprocessor
Syntax/Description