×
Everything you do now is for your future. Think About that.
--Your friends at LectureNotes
Close

Note for C Language - C by LALIT KUMAR MAHANTA

  • C Language - C
  • Note
  • Computer Science Engineering
  • B.Tech
  • 18 Views
  • 3 Offline Downloads
  • Uploaded 3 months ago
Lalit Kumar Mahanta
Lalit Kumar Mahanta
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

Module – I Introduction to Computer: Computer is an electronic device that is designed to work with Information. The term ‘computer is derived from the Latin term ‘computare’, this means to calculate. Computer cannot do anything without a Program. It represents the decimal numbers through a string of binary digits. The Word 'Computer’ usually refers to the Central Processor Unit plus Internal memory. Computer is an advanced electronic device that takes raw data as input from the user and processes these data under the control of set of instructions (called program) and gives the result (output) and saves output for the future use. It can process both numerical and non-numerical (arithmetic and logical) calculations. The basic components of a modern digital computer are: Input Device, Output Device, and Central Processor. A Typical modern computer uses LSI Chips. Charles Babbage is called the "Grand Father" of the computer. The First mechanical computer designed by Charles Babbage was called Analytical Engine. It uses read-only memory in the form of punch cards. Four functions about computer are: input (accepts data), processing (processed data), output (produces output), and Storage (stores results). INPUT DATA: Input is the raw information entered into a computer from the input devices. It is the collection of letters, numbers, images etc. PROCESS: It is the operation of data as per given instruction. It is totally internal process of the computer system. OUTPUT: It is the processed data given by computer after data processing. Output is also called as Result. STORAGE: We can save the results in the storage devices for the future use. Algorithm: An algorithm is a procedure or formula for solving a problem. an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, will proceed through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.

Text from page-2

Flowchart: A flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting these with arrows. This diagrammatic representation can give a step-by-step solution to a given problem. Process operations are represented in these boxes, and arrows connecting them represent flow of control. Data flows are not typically represented in a flowchart, in contrast with data flow diagrams; rather, they are implied by the sequencing of operations. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields Flowchart Symbols:

Text from page-3

Structured Programming Approach: During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach to program design was based on the following method: • • • To solve a large problem, break the problem into several pieces and work on each piece separately; To solve each piece, treat it as a new problem that can itself be broken down into smaller problems; Repeat the process with each new piece until each can be solved directly, without further decomposition. This approach is also called top-down program design. The following is a simple example of the structured programming approach to problem solving. Write a program for a computer to execute to display the average of two numbers entered through a keyboard connected to the computer. The average is to be displayed on a VDU that is also connected to this computer.

Text from page-4

The top-down solution is arrived at as follows: Top level: 0. Display average of two numbers entered through keyboard Next level: 0.1. Get two numbers through keyboard 0.2. Calculate average of these two numbers 0.3. Display average on VDU The three steps in next level can now be coded in a programming language such as Pascal. Top-down program design is a useful and often-used approach to problem solving. However, it has limitations: • • • It focuses almost entirely on producing the instructions necessary to solve a problem. The design of the data structures is an activity that is just as important but is largely outside of the scope of top-down design. It is difficult to reuse work done for other projects. By starting with a particular problem and subdividing it into convenient pieces, top-down program design tends to produce a design that is unique to that problem. Adapting a piece of programming from another project usually involves a lot of effort and time. Some problems by their very nature do not fit the model that top-down program design is based upon. Their solution cannot be expressed easily in a particular sequence of instructions. When the order in which instructions are to be executed cannot be determined in advance, easily, a different approach is required. Top-down design was therefore combined with bottom-up design. C Programming: The C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the UNIX operating system. C is the most widely used computer language. C - Built-in Library Functions: String Manipulation Functions • • • • • char *strcpy (char *dest, char *src); : Copy src string into dest string. char *strncpy(char *string1, char *string2, int n); : Copy first n characters of string2 to stringl . int strcmp(char *string1, char *string2); : Compare string1 and string2 to determine alphabetic order. int strncmp(char *string1, char *string2, int n); : Compare first n characters of two strings. int strlen(char *string); : Determine the length of a string.

Lecture Notes