0% found this document useful (0 votes)
4 views

unit 2 qb

The document provides definitions and explanations of various programming concepts in C, including functions like scanf() and printf(), decision-making and looping statements, and array declarations. It also covers searching and sorting algorithms, specifically selection sort, and includes a detailed outline of topics for a C programming course. Additionally, it lists subjects for different semesters in an engineering curriculum.
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 views

unit 2 qb

The document provides definitions and explanations of various programming concepts in C, including functions like scanf() and printf(), decision-making and looping statements, and array declarations. It also covers searching and sorting algorithms, specifically selection sort, and includes a detailed outline of topics for a C programming course. Additionally, it lists subjects for different semesters in an engineering curriculum.
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/ 7

www.Poriyaan.

in
4931_Grace College of Engineering, Thoothukudi

TWO MARKS
1.Define scanf() function:
Scan f () function is used to read the value from the input device.

2.Define printf () function:


Print f ()function is used to display data on the monitor.

3.Define decision making statement:


These statements are used to execute particular set of instruction for based on cert ain
condition.
Ex:if, if else, nested if, if else if ladder, switch.

4.Define looping statement :


Looping statement are used to execute a group of instruction repeatedly at till some
condition is satisfied.
Example: while, do while, for loop.

5.Define unconditional statement:


This condition is used to transfer the control to other statement without checking any
condition.
Example : goto, break.

6.Define simple if statement:


It is used to execute some statements for a particular condition.

7.Define switch statement :

is a multi branch decision statement.

8.Define for statement :


The for loop is entry controlled loop that provides a more concise loop control structure.

9.Define goto statement:


Goto statement can transfer the control to any place in a program. It is useful to provide
branching within a loop.

10.Define break statement:


Break statement exit from the loop can be accomplished by using the break statement.

11.Define exit statement:


It is used to terminate the program it is same as break statement.

12.what is getchar() :
Getchar () function is used to read one character at a time from the standard input
device.

CS3251_PIC

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 2
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

13.Define putchar() :
Single character can be displayed using the function putchar(). The function putchar()

14. Define Array


Array is a collection of similar type of values
All values are stored in continuous memory locations
All values share a common name
Linear data structure. The elements are organized in a sequential order.

15. Name any two library functions for handling string


strlen() finds the length of a string. It returns an integer value. It counts the no. of
characters except null character & returns the count
strlen(str)
strcpy() copies the source string into destination string. So, the source string should
be enough to store the destination string.
strcpy(source,destination)

3. Declare a float array of size 5 and assign 5 values to it

Declaration : float price[5];


Initialization : float price[5]={200.50,150.25,25.5,55.75,40.00}; (or)
float price[]={1.2,3.4,6.5,7.8,9.8};

4. Give an example for initialization of string array

String is a character array.


Collection of one or more characters- enclosed with in double quotes
Declaration : char name[10];

5. How a character array is is declared

Declaration : char name[n];


This array can store n-1 characters.

6. Write example code to declare two dimensional array

Two dimensional array is an array with two subscript values. First subscript specifies the
row & second subscript specifies the column. Used to process matrix operations.
Declaration : datatype array_name [r][c];

CS3251_PIC

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 3
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

int matrixA[10][10];
This matrixA can store 100 elements in a row major order.

7. What is mean & median of a list of elements?

Mean : Average of the N elements can be computed by


sum of N elements/N
Ex: 2,1,3,4,5
Mean = (2+1+3+4+5)/5 = 3
Median : Middle element of a list. To find the median, the list must be sorted first.
If N is odd then Median= (N+1)/2
Ex: 1,2,3,4,5
Median= 6/2 . The element at 3rd position is the median
If N is even then then Median is the average of
Median= (a[(N+1)/2]+a[(N-1)/2])/2
Ex: 1,2,3,4,5,6
Median=(a[3]+a[2])/2
=4+3/2
=3.5

8. Define Searching

Searching is a process of finding the position of a given element in a list. The searching
is successful if the element is found. There are two types of searching.
Linear Search
Binary Search

9. Define Sorting

Sorting is a process of arranging the elements either in ascending order or descending


order.

10. Sort the following elements using selection sort method. 23,55,16,78,2

Step1:Find smallest element in the list & exchange the element with first element of the
list
2,55,16,78,23
Step2: Find second smallest value & exchange it with the second element of the list
2,16,55,78,23
Step 3: Continue the process until all the elements are arranged in the order
2,16,23,78,55
Step 4: 2,16,23,55,78

CS3251_PIC

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 4
www.Poriyaan.in
4931_Grace College of Engineering, Thoothukudi

PART B
1.Explain Selection Sort in C

2. Explain Linear search in C

3. Explain binary search in C

4.Explain in detail about One - dimensional Array

5.Explain in detail about Two Dimensional Array

6.Explain in detail about String Operations

7.Write a c program for 3 X 3 Matrics Multiplication

CS3251_PIC

https://play.google.com/store/apps/details?id=com.poriyaan.poriyaan 5
Programming in C

Unit I (a): Introduction to Programming


Introduction to Computer Software | Classification of Computer Software | Programming Languages |
Generation of Programming Languages
Unit I (b): Introduction to C
Introduction, Background, Characteristics, Uses of C Programming | Structure of a C Program | Writing the First
C Program | Files Used in a C Program | Compiling and Executing C Programs | Using Comments | C Tokens |
Character Set in C | Keywords | Identifiers | Basic Data Types in C | Variables | Constants | Input/Output |
Statements in C | Operators in C | Type Conversion and Typecasting
Unit I (c): Decision Control and Looping Statements
Introduction to Decision Control Statements | Conditional Branching Statements | Iterative Statements | Nested
Loops | The Break and Continue Statements | goto Statement
Unit I (d): Preprocessor Directives
Introduction of Preprocessor Directives | Types of Preprocessor Directives | #define | #include | #undef | #line |
Pragma Directives | Conditional Directives | Defined Operator | #Error Directive | Predefined Macro Names
Unit II (a): Arrays
Introduction to Arrays in C Programming | Declaration of Array in C | Accessing the Elements of an Array in C |
Storing Values in Arrays | Operations on Arrays | Passing Arrays to Functions | Two-Dimensional Arrays |
Operations on Two-Dimensional Arrays | Passing Two-Dimensional Arrays to Functions | Multidimensional
Arrays | Sparse Matrices (Array Representation) | Applications of Arrays
Unit II (b): Strings
Introduction to Strings in C | Suppressing Input | Strings Taxonomy | Operations on Strings | Miscellaneous
String and Character Functions | Arrays of Strings
Unit III (a): Functions
Introduction to Functions | Using Functions | Function Declaration/Function prototype | Function Definition |
Function Call | Return Statement | Passing Parameters to Functions | Scope of Variables | Storage Classes |
Recursive Functions | Types of Recursion | Tower of Hanoi (recursion) | Recursion Versus Iteration
Unit III (b): Pointers
Understanding the Computer's Memory | Introduction to Pointers | Declaring Pointer Variables | Pointer
Expressions and Pointer Arithmetic | Null Pointers | Generic Pointers | Passing Arguments to Function Using
Pointers | Pointers and Arrays | Passing an Array to Functions | Difference Between Array Name and Pointer |
Pointers and Strings | Arrays of Pointers | Pointers and 2D Arrays | Pointers and 3D Arrays | Function Pointers |
Array of Function Pointers | Pointers to Pointers | Memory Allocation in C Programs | Memory Usage | Dynamic
Memory Allocation | Drawbacks of Pointers
Unit IV: Structures and Union
Structure | Nested Structures | Arrays of Structures | Structure and Functions | Self-referential Structures |
Unions | Arrays of Union Variables | Unions Inside Structures | Structures Inside Unions | Enumerated Data Type
| Memory Allocation and Deallocation for a Linked List | Singly Linked Lists
Unit V: File Processing
Introduction to Files | Using Files in C | Read Data From Files | Writing Data From Files | Detecting the End-of-
File | Error Handling During File Operations | Accepting Command Line Arguments | Function for Selecting a
Record Randomly | Remove()| Renaming the File | Creating a Temporary File
All 2nd Semester Subjects
Professional English - II - HS3252 Engineering Graphics - GE3251
Statistics and Numerical Methods - Physics for Electronics Engineering -
MA3251 PH3254
Physics for Electrical Engineering - Physics for Civil Engineering - PH3201
PH3202
Materials Science - PH3251 Basic Electrical and Electronics
Engineering - BE3251
Physics for Information Science - Basic Civil and Mechanical Engineering -
PH3256 BE3255
Basic Electrical and Instrumentation Electric Circuit Analysis (Circuit
Engineering - BE3254 Theory) - EE3251
Programming in C - CS3251 Circuit Analysis - EC3251
Data Structures Design - AD3251
Civil
CSE
Home Mech

EEE
ECE

2nd Semester 3rd Semester


1st Semester
Professional English II Discrete Mathematics
Professional English I
Statistics and Numerical
Methods Digital Principles and
Matrices and Calculus
Computer Organization
Engineering Graphics
Engineering Physics
Foundation of Data
Physics for Information
Science Science
Engineering Chemistry

Basic Electrical and Data Structure


Problem Solving and Electronics Engineering
Python Programming Object Oriented
Programming in C
Programming

4th Semester 5th Semester 6th Semester


Theory of Computation Computer Networks Object Oriented Software
Engineering
Artificial Intelligence Compiler Design
and Machine Learning Embedded Systems IoT
Cryptography and
Database Management Cyber Security Open Elective I
System
Professional Elective III
Algorithms Distributed Computing
Professional Elective IV

Introduction to Operating Professional Elective I Professional Elective V


Systems
Professional Elective II Professional Elective VI
Environmental Sciences
and sustainability Mandatory Course I Mandatory Course II

7th Semester 8th Semester


Human Values and Ethics Project Work/Internship

Elective-Management

Professional Elective II

Professional Elective III

Professional Elective IV

You might also like