Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming for Problem Solving: C Programming Language Course Material - Prof. Visvera, Schemes and Mind Maps of C programming

In this you will get about c Language in very easy way all topic are coverd like pointers and files all topics are there so download and start learning

Typology: Schemes and Mind Maps

2020/2021

Available from 01/19/2022

ashish-singh-26
ashish-singh-26 🇮🇳

1 document

1 / 284

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
[programming for problem solving -course material]
PROGRAMMING FOR PROBLEM SOLVING
COURSE - MATERIAL
COURSE FILE FOR
THE ACADEMIC
YEAR 2018-19
COURSE: I YEAR B.TECH
SUBJECT: PROGRAMMING FOR
PROBLEM SOLVING
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Programming for Problem Solving: C Programming Language Course Material - Prof. Visvera and more Schemes and Mind Maps C programming in PDF only on Docsity!

PROGRAMMING FOR PROBLEM SOLVING COURSE MATERIAL

COURSE FILE FOR

THE ACADEMIC

YEAR 2018-

COURSE: I YEAR B.TECH

SUBJECT: PROGRAMMING FOR

PROBLEM SOLVING

Vision and Mission of the Institute:

VISION To be recognized as a premier institution in offering value based and futuristic quality technical education to meet the technological needs of the society MISSION  To impart value based quality technical education through innovative teaching and learning methods  To continuously produce employable technical graduates with advanced technical skills to meet the current and future technological needs of the society  To prepare the graduates for higher learning with emphasis on academic and industrial research

Vision , Mission &PEOs of the Department of CSE

VISION

To produce globally competent and industry ready graduates in Computer Science & Engineering by imparting quality education with a know-how of cutting edge technology and holistic personality MISSION  To offer high quality education in Computer Science & Engineering in order to build core competence for the graduates by laying solid foundation in Applied Mathematics, and program framework with a focus on concept building  The department promotes excellence in teaching, research, and collaborative activities to prepare graduates for professional career or higher studies  Creating intellectual environment for developing logical skills and problem solving strategies, thus to develop, able and proficient computer engineer to compete in the current global scenario Program Educational Objectives (PEOs)  Excel in professional career or higher education by acquiring knowledge in mathematical,  computing and engineering principles  To provide intellectual environment for analyzing and designing computing systems for technical needs  Exhibit professionalism, multidisciplinary teamwork and adapt to current

  1. The graduates communicate effectively with lifelong learning attitude and function as responsible members of global society

PROGRAM OUTCOMES

  1. Engineering knowledge: An ability to apply knowledge of computing, mathematics, science and engineering fundamentals appropriate to the discipline
  2. Problem analysis: An ability to analyze a problem, and identify and formulate the Computing requirements appropriate to its solution
  3. Design/development of solutions: An ability to design, implement, and evaluate a Computer-based system, process, component, or program to meet desired needs With appropriate consideration for public health and safety, cultural, societal And environmental considerations
    1. Conduct investigations of complex problems: An ability to design and conduct experiments, as well as to analyze and interpret data
  4. Modern tool usage: An ability to use current techniques, skills, and modern tools necessary for computing practice
  5. The engineer and society: An ability to analyze the local and global impact of Computing on individuals, organizations, and society
  6. Environment and sustainability: Knowledge of contemporary issues
  7. Ethics: An understanding of professional, ethical, legal, security and social issues and responsibilities
  8. Individual and team work: An ability to function effectively individually and on teams, including diverse and multidisciplinary, to accomplish a common goal
  9. Communication: An ability to communicate effectively with a range of audiences
  10. Project management and finance: An understanding of engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects
  11. Life-long learning: Recognition of the need for and an ability to engage in continuing professional development

PROGRAMMING FOR PROBLEM SOLVING SUBJECT COURSE OUT-COMES

CO1 Demonstrate computer System and Software development process

CO2 Design algorithms and develop programs involving selection structures andlooping structures.

CO3 Implement memory management techniques perform string processing andOrganize heterogeneous data.

CO4 Organize files to manage large amount of data.

CO5 Design and develop large programs using functions and arrays.

CO6 Implement Searching and Sorting techniques

INTRODUCTION

Computer technology plays an increasing role in the information revolution. Today, the application of computers is all pervasive in everybody’s life. A sound knowledge of how computers process data and information has, therefore, become indispensable for anyone who seeks employment not only in the area of IT but also in any other field.

COMPUTER PROGRAMMING Computer Programming is dedicated to writing, testing and maintaining programs that computers follow to perform their functions. To create programs that control the behavior of a machine, we need programming languages. This book enables students to master the necessary skills for computer programming with C language shows them how to use these skills wisely with data structures and algorithms.

C PROGRAMMING LANGUAGE C is a general-purpose structured programming language that is powerful, efficient and compact. C combines the features of high-level language with the elements of the assembler and is thus close to both man and machine. The growth of C during the last few years has been phenomenal. It has emerged as the language of choice for most applications due to speed, portability and compactness of code. It has now been implemented on virtually every sort of computer, from micro to mainframe.

HOW IS THE BOOK ORGANIZED The book covers the basic anatomy of a computer system, input devices, processor, output devices and memory management and also discusses algorithms and flowcharts in Unit-I. Unit I also introduces programming in C language, which talks about the basic structure of C programs and their execution, how to declare constants, variables and data types, details the input and output operations, built-in operators and how to build expressions using them and also covers decision making and looping structures. Unit-II provides detailed exposition of Arrays, Pointers, structures, Strings and the basic concepts of file are covered in Unit-III. Unit-IV covers the concepts of

arrays of strings Structures: Defining structures, initializing structures, unions, Array of structures Pointers: Idea of pointers, Defining pointers, Pointers to Arrays and Structures, Use of Pointers in self-referential structures, usage of self referential structures in linked list (no implementation) Enumeration data type

Unit - III: Preprocessor and File handling in C: Preprocessor: Commonly used Preprocessor commands like include, define, undef, if, ifdef, ifndef Files: Text and Binary files, Creating and Reading and writing text and binary files, Appending data to existing files, Writing and reading structures using binary files, Random access using fseek, ftell and rewind functions.

Unit - IV: Function and Dynamic Memory Allocation:

Functions: Designing structured programs, Declaring a function, Signature of a function, Parameters and return type of a function, passing parameters to functions, call by value, Passing arrays to functions, passing pointers to functions, idea of call by reference, Some C standard functions and libraries Recursion: Simple programs, such as Finding Factorial, Fibonacci series etc., Limitations of Recursive functions Dynamic memory allocation: Allocating and freeing memory, Allocating memory for arrays of different data types

Unit - V: Introduction to Algorithms: Algorithms for finding roots of a quadratic equations, finding minimum and maximum numbers of a given set, finding if a number is prime number, etc. Basic searching in an array of elements (linear and binary search techniques), Basic algorithms to sort array of elements (Bubble, Insertion and Selection sort algorithms), Basic concept of order of complexity through the example programs

TEXT BOOKS:

  1. Byron Gottfried, Schaum’s Outline of Programming with C, McGraw-Hill
  2. B.A. Forouzan and R.F. Gilberg C Programming and Data Structures, Cengage Learning, (3rd Edition)

REFERENCE BOOKS:

  1. Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, Prentice
  2. Hall of India
  3. R.G. Dromey, How to solve it by Computer, Pearson (16th Impression)
  4. Programming in C, Stephen G. Kochan, Fourth Edition, Pearson Education.
  5. Herbert Schildt, C: The Complete Reference, Mc Graw Hill, 4th Edition

SESSION PLANNER/LESSON PLANNER

L17&L18 conditionals and consequent branching with if, if-else, switch-case, ternary operator, goto,

T1&T

L19&L20 Iteration with for, while, do- while loops

T1&T

Input and Output L21 Simple input and output with scanf and printf, formatted I/O,

T1&T

L22 Introduction to stdin, stdout and stderr. Command line arguments

T1&T

unit -II (Arrays,strings,structures and pointers)

Arrays L23&L24 creating, accessing and manipulating elements of arrays -one Dimensional array

T1&T

L25,L26&L27 creating, accessing and manipulating elements of arrays -Two Dimensional array

T1&T

Strings: L28 Introduction to strings, handling strings as array of characters

T1,T2&R

L29&L30 basic string functions available in C (strlen, strcat, strcpy, strstr etc.)

T1,T2&R

L31 arrays of strings T1&T Structures: L32 Defining structures, initializing structures&Accessing

T1&T

L33 unions& Array of structures T1&T Pointers: L34 Idea of pointers, Defining pointers,

T1&T

L35 Pointers to Arrays and Structures

T1&T

L36 Use of Pointers in self- referential structures, usage of self referential structures in linked list

T1&T

L37 Enumeration data type T1&T

UNIT- III (preprocessor and file handling)

Preprocessor: L38 Commonly used Preprocessor commands like include, define, undef, if, ifdef, ifndef

T1&T

Files: L39 Text and Binary files T1&T L40&L41 Creating and Reading and writing text and binary files, Appending data to existing files

T1&T

L42 Writing and reading structures using binary files,

T1&T

L43 Random access using fseek, ftell and rewind functions.

T1&T

UNIT- IV (Function and Dynamic Memory Allocation)

Functions: L44 Designing structured programs, Declaring a function

T1&T

L45 Signature of a function, Parameters and return type of a function

T1&T

L46 passing parameters to functions, call by value &call by reference,

T1&T

L47&L48 Passing arrays to functions, passing pointers to functions

T1&T

Recursion: L49 Simple programs, such as Finding Factorial, Fibonacci series

T1&T

Dynamic memory allocation

INDEX
UNIT CONTENT PAGE NUMBER

Introduction to components of computer system

Introduction to Algorithms 37-

Introduction to C Programming Language:

Conditional Branching and Loops 73-
Input and Output 91-
Arrays 99-
Strings 118-
Structures 130-
Pointers 143-
Preprocessor 151-
Files 157-
Functions 187-
Dynamic memory allocation 206-
Introduction to Algorithms 213-
Soritng 216-
Searching and Soritng 228-
Objective Type questions 233-

JNTUH Previous Question papers

COMPUTE R SYSTEM

HARDWAR E SOFTWAR E

1.1 INTRODUCTION TO PROGRAMMING

A Program is a set of instructions given to the computer to do various tasks what the user

wishes too. The instructions can be in the form of commands also. A Program(or) Instructions

(or) commands are given by the user to computer to fulfill the desired task. As computer cannot

understand human language so it needs the translators like compiler, interpreter, assembler to

convert the human language of instructions to binary.

1.2 Introduction to Computers systems:

i)DEFINITION OF COMPUTER:

 It is a high speed electronic device.  It helps to store large volumes of data safely and securely & retrieves it whenever required by the user.  It receives input from user through input devices, process it, and sends output through output devices to user again

INPUT OUTPUT

(raw data/instructions) “Information “ i.e Processed Data

COMPUTER SYSTEMS:  It is made up of 2 major components  They are :

  1. Hardware
  2. Software

16

Computer Hardware :

 These are the physical components of a computer  It consists of 5 Parts

  1. Input Devices 4) Primary Storage
  2. Output Devices 5) Secondary Storage
  3. CPU Block diagram of a Computer

Input Devices

 These are used to enter data and programs into the computer

 These are for man to machine communication

Ex: Keyboard, mouse, scanner, touch screen, audio input, Digitizer, light pen, joysticks, Track ball, Space ball, z-mouse, Digital Camera, Microphone, finger print reader, barcode reader, Data Glove, web cam,

Output Devices

 These are used to get the desired output from the computer  These are for machine to man communication

ALU CU

Primary Memory

Input Device s

Output Device s

Secondary Memory

Hard drives A hard-disk drive (HDD) is a non-volatile device used for storage, located inside the computer case. Like the floppy drive, it holds its data on rotating platters with a magnetic upper exterior which are changed or read by electromagnetic tipped arms that move over the disk as it spins.

1.2.2 Memory

A memory is just like a human brain. It is used to store data and instructions. The memory is divided into large number of small parts called cells. Each location or cell has a unique address, which varies from zero to memory size minus one. For example, if the computer has 64k words, then this memory unit has 64 * 1024 = 65536 memory locations. The address of these locations varies from 0 to 65535.

Memory is used for storage of data and programs. It is divided into 2 parts.

  1. Primary Memory/ Main Memory
  2. Secondary Memory/ Auxiliary Memory
  3. Cache Memory 1.Primary Memory  It is also called main memory or volatile memory.  Data is stored temporarily i.e. data gets erased when computer is turned off.  Faster than secondary memories.  A computer cannot run without the primary memory  Eg: RAM ,ROM

1)RAM(random access memory)  It is the internal memory of the CPU for storing data, program, and program result.  It is a read/write memory which stores data until the machine is working.  once the machine is switched off, data is erased. RAM is of two types −  Static RAM (SRAM)  Dynamic RAM (DRAM)

1)SRAM(static RAM) : The word static indicates that the memory retains its contents as long

as power is being supplied.

Characteristic of Static RAM

 Long life  No need to refresh

 Faster

 Used as cache memory

 Large size

 Expensive

 High power consumption

2) DRAM(Dynamic Random Access Memory)

 DRAM is used for most system memory as it is cheap and small.  All DRAMs are made up of memory cells, which are composed of one capacitor and one transistor.

Characteristics of Dynamic RAM

 Short data lifetime  Needs to be refreshed continuously

 Slower as compared to SRAM

 Used as RAM

 Smaller in size

 Less expensive

 Less power consumption