Vous êtes sur la page 1sur 14

Table of contents

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

Chapter 1: Problem solving with Computer


1.1 Introduction

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.

How to solve a problem?


There are various steps in order to solve a problem. 1. Develop an algorithm and a flowchart. 2. Write the program in computer language. 3. Enter the program into computer. 4. Test and debug the program. 5. Run the program, input data and get the results from the computer.
1.1.1

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.

Basic flowchart symbols


1. Start/Stop: Used to determine the start and end points of flowchart

2. Decision Box: Used to make logical decision.

3. Input/Output: Used for input and output.

4. Connector: Connects one part of the flowchart to another.

5. Process Box: Used for Calculation and Storage.

6. Flow Direction: Used to indicate the direction of flow at certain point.

Example 1: Finding the sum of two numbers. Algorithm: 1. 2. 3. 4. 5. 6. Flowchart:


Start Read A aaAAA AA

Start Input A Input B Calculate C = A + B Output C Stop

Read B

C=A+B

Print C

Stop

Advantages of using Flowcharts


1. 2. 3. 4. 5. Communication Effective analysis Proper Documentation Efficient Coding Proper Debugging

6. Efficient Program Maintenance

Limitations of using Flowcharts


1. Complex logic

2. Alterations and Modifications 3. Reproduction

1.1.3 PSEUDO CODE


These are basically the instructions written in plain English language to solve any problem. Pseudo is a way of describing an algorithm without using any specific programming language. Pseudo code can also be said to be a language independent code. It means you can convert it to any language like C, C++, Java, VB and many more. C programs are basically related to a human language like English. In order to develop a program you will need the following ingredients. 1. Language constructs 2. Decision statements 3. Looping statements For Example: If total is greater than 60 Print pass Else Print fail

********************End of Chapter 1**********************

Chapter 2: The Programming Process


Introduction
All Programming involves creating something that solves a problem. There are various things that we take while entering the land of programming. In broad terms, those things are: 1. Identify the problem. 2. Design the solution. 3. Write the program. 4. Check the solution. Of these, only the third step is usually called programming, but you will see later, its probably the least important stage of the process. `

2.1 Identify the problem


This stage should really be called identifying the solution. There are two stages to identifying a solution: Requirements Specifications

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.2 Design a solution


Once you have identified the things required to solve your problem and specified what form your solution will take, the next step is to work out just how you are going to turn that specification into a working program. This is usually the hardest task! As mentioned before, a program is simply a list of steps describing to the computer what it should do. A design is simply a higher level description of those steps. In effects it is a program written as if the computer is a person. So it does not have to completely spell out.

2.3 Write the program


Programming is then the task of describing your design to the computer & teaching it your way of solving the problem. There are usually three stages to write a program: 1. Coding 2. Compiling 3. Debugging

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.

2.4 Check the solution


Once all the testing and debugging gas been completed, you should be pretty certain that your program works according to your requirements & specifications and you should finally have a solution to your problem.

********************End of Chapter 2**********************

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.

Modularity: Ability to breakdown a large module into manageable sub


modules called as modularity that is an important feature of structured programming languages.

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.

3.3 The simplest C program


C is a high level programming language and that you need a C compiler to translate your C programs into binary code that your computer can understand and execute. In this chapter we will write a simple C program and the basics of that c program. /* This is my first C program */ 1. #include<stdio.h> 2. Void main() 3. { 4. Printf(Hello World); 5. }

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.

***********************End of Chapter 3************************

Vous aimerez peut-être aussi