C
C
C
Chapter 1: Problem Solving with Computer 1.1 Introduction 1.1.1 Algorithm 1.1.2 Flowchart 1.1.3 Pseudo code Chapter 2: The Programming Process 2.1 Identify the problem 2.1.1 Requirements 2.1.2 Specifications 2.2 Design a Solution 2.3 Write the program 2.3.1 Coding 2.3.2 Compiling 2.3.3 Debugging 2.4 Check the Solution Chapter 3: Introduction to C 3.1 Evolution of C 3.2 Characteristics of C 3.3 The simplest C program Chapter 4: Building Blocks 4.1 C Character Set 4.2 Identifiers and Keywords 4.2.1 Identifiers 4.2.2 Keywords 4.3 Constants and variables 4.4 Data Types in c 4.4.1 Fundamental data Types 4.4.2 Data type Modifiers Chapter 5: Operators, Expressions and I/O statements 5.1 C- Operator Types 5.1.1 Arithmetic Operators 5.1.2 Unary Operators 5.1.3 Binary Operators 5.1.4 Logical Operators 5.1.5 Relational Operators 5.1.6 Assignment Operators 5.1.7 Increment & Decrement Operators 5.1.8 Bitwise Operators 5.1.9 Special Operators
5.2 Type Conversions in expressions 5.2.1 Implicit type Conversion 5.2.2 Explicit type Conversion 5.3 Input and Output Statements 5.4 Library Functions Chapter 6: Control Statements 6.1 Control Statements 6.1.1 Conditional Statements 6.1.1.1 If, if-else, if-else-if statements 6.1.1.2The Switch Statements 6.1.2 Loop Statements 6.1.2.1 The for statement 6.1.2.2 The while statement 6.2.1.3 The do-while statement 6.1.3 Branching & jumping statements 6.1.3.1 The break Statement 6.1.3.2 The continue Statement 6.1.3.3 The go to Statement 6.1.3.4 The exit () Statement
Computer is a problem-solving tool. We use computer in order to solve our problems. Method of Problem Solving 1. Recognize & understand the problem. 2. Accumulate facts. 3. Select appropriate theory. 4. Make necessary assumptions. 5. Solve the problem. 6. Verify results.
Algorithm
An Algorithm is just a detailed sequence of simple steps that are needed to solve a problem. We process step by step to find the solution. The development of proper procedure is called Algorithm.
Example 1:
Q: Obtain the sum of two numbers. The numbers may have any value. Let the numbers be X and Y respectively. Step 1. Read the value of X and Y Step 2. Add X and Y and call it Z Step 3. Write the value of Z Step 4. Stop
Example 2:
Q: Compare two numbers and print the largest number. Assume the numbers are A and B. Step 1. Read the value of A and B Step 2. Compare the value of A and B Step 3. If A>B then go to step 4 else go to step 6 Step 4. Write the value of A Step 5. Stop Step 6. Write the value of b Step 7. Stop
1.1.2 Flowchart
A flowchart is a graphical representation of an algorithm. A flowchart is defined as a pictorial representation of how to solve the problem. Drawing flowchart is the second step of any programming. After writing algorithm we need to draw flowchart. In this we use geometric symbols which have its own meaning and significance in the flowchart. Each symbol is connected with another with an arrow key which shows the direction of flow of the program logic.
1.
Four particular types of flowcharts have proven useful while dealing with a process analysis:
Document flowcharts: showing a document show through system. 2. Data flowcharts: Showing data flows in a system. 3. System flowcharts: Showing control at a physical or resource level. 4. Program flowchart: Showing the controls in a program within a system.
Read B
C=A+B
Print C
Stop
2.1.1 Requirements
The first step is to examine the problem carefully to identify what qualifies as a solution. A single problem may have many different solutions, but they will all have something in common. So we proceed according to the requirement of solution. We will choose the best method to solve our problem.
2.1.2 Specifications
The second step is to look at the list of requirements and to decide exactly what your solution should do to fulfill them. There are usually many different solutions to a single problem. Here your aim is to decide on which of those solution you want. Therefore you are trying
to specify in a fairly accurate manner, just what it is your final program will do.
2.3.1 Coding
Coding is the act of translating the design into an actual program, writing in some form of programming language. This is the step where you actually have to sit down at the computer and type. Coding is little bit like writing an essay. There are certain things that you always need to include in your program. When you have finished translating your design into a program, you need to submit it to the computer to see what it makes of it.
2.3.2 Compiling
Compiler is a tool which converts the program into machine language. Computer can only understand the binary language. Compilation is
actually the process of turning the program written in some programming language into the instruction made up of 0s and 1s that the computer can actually follow. 2.3.3 Debugging
After compilation, a list of errors/bugs is shown which represents the problems in the program. We try to find out the nature of these errors. We compile again and again and solve the errors. Once our program is free of bugs, it is ready to get executed.
Chapter 3: Introduction to C
Introduction
C was developed by Dennis Ritchie at Bell Laboratories in 1972. Most of its principles and ideas were taken from the earlier language B, BCPL and CPL. CPL was developed jointly between the Mathematical Laboratory at the University of Cambridge and the University of London Computer Unit in 1960s. CPL (Combined Programming Language) was developed with the purpose of creating a language that was capable of both machine independent programming and would allow the programmer to control the behavior of individual bits of information. But the CPL was too large for use in many applications. In 1967, BCPL (Basic Combined Programming Language) was created as a scaled down version of CPL while still retaining its basic features. This process was continued by Ken Thompson. He made B Language during working at Bell Labs. B Language was a scaled down version of BCPL. B Language was written for the systems programming. In 1972, a co-worker of Ken Thompson, Dennis Ritchie developed C Language by taking some of the generality found in BCPL to the B language. The original PDP-11 version of the UNIX system was developed in assembly language. In 1973, C language had become powerful enough that most of the UNIX kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly.
3.1Evolution of C
During the rest of the 1970's, C spread throughout many colleges and universities because of its close ties to UNIX and the availability of C compilers. Soon, many different organizations began using their own versions of C Language. This was causing great compatibility problems. In 1983, the American National Standards Institute (ANSI) formed a committee to establish a standard definition of C Language. That is known as ANSI Standard C. Today C is the most widely used System Programming Language.
3.2Characterstics of C
There are various characteristics of C. These are 1. Modularity. 2. Portability. 3. Extendibility. 4. Speed. 5. Flexibility.
Advantages:
1. Projects can be completed in time. 2. Debugging will be easier and faster.
Portability:
The ability to port i.e. to install the software in different platform is called portability. Highest degree of portability: C language offers highest degree of portability i.e., percentage of changes to be made to the sources code is at minimum when the software is to be loaded in another platform. Percentage of changes to the source code is minimum. The software that is 100% portable is also called as platform independent software or architecture neutral software. E.g.: Java.
Extendibility:
Ability to extend the existing software by adding new features is called as extendibility.
SPEED:
C is also called as middle level language because programs written in c language run at the speeds matching to that of the same programs written in assembly language so c language has both the merits of high level and middle level language and because if this feature it is mainly used in developing system software.
Flexibility:
Key words or reverse words. ANSIC has 32 reverse words. C language has right number of reverse words which allows the programmers to have complete control on the language.
This is a very simple program which you can save with any name with extension .c. #include <stdio.h> is a header file which is a standard input output file. Void is a keyword. Main() is a function. Printf is an output function.