Research Paper On C Programming

Submitted By pumbama
Words: 973
Pages: 4

UNIVERSITY OF EAST LONDON

SCHOOL of COMPUTING, INFORMATION TECHNOLOGY & ENGINEERING

1. introduction to c programming 1

1.1 A First C Program 3
1.1.1 Comments 3
1.1.2 Header Files, Pre-processing and #include 4
1.1.3 Function main() 4
1.1.4 Strings, Escape Sequences and a first look at printf () 4
1.1.5 Simple Print Exercises 6
1.2 Identifiers 7
1.3 Variable Types and Declarations 8
1.3.1 Integers 8
1.3.2 Floating-point numbers 8
1.3.3 Characters 8
1.4 Manipulating Data: Basic Operations 10
1.4.1 The Assignment Operator 10
1.4.2 Arithmetic Operators 10
1.4.3 Symbolic Constants 11
1.4.4 Mathematical Functions 12
1.5 Input and Output 14
1.5.1 The printf() function revisited 14
1.5.2 Initialisation of variables 17
1.5.3 The scanf () function 18
1.5.4 Some simple program examples 19
1.6 Simple Program Exercises 21

2. Control Statements 22

2.1 Operators 22
2.1.1 Relational Operators 22
2.1.2 Logical Operators 22
2.2 Selection Statements 23
2.2.1 The if else statement 23
2.2.2 The switch statement 29
2.3 Control Statement Exercises 32
2.4 Loops 33
2.4.1 The for loop 33
2.4.2 The while loop 36
2.4.3 The do-while loop 40
2.5 Loop Exercises 41

3. Arrays 42

3.1 One-dimensional arrays 43
3.1.1 Entering data into an Array 43
3.2 Multiple-dimensional arrays 46
3.3 Array Exercises 48

4. Functions 49

4.1 User-Defined Functions 49
4.2 Function Prototypes 50
4.3 Calling Functions: Call by Value and Call by Reference 51
4.4 Local and Global Variables 52
4.4.1 Local Variables 52
4.4.2 Global Variables 53
4.5 Function Exercises 54

1. introduction to c programming

Understanding the C language is one hurdle that a student new to computer programming has to face. The other, and probably the more important hurdle, is understanding the problem that has to be solved. Not fully understanding the problem so be solved often leads to bad computer code that is a) difficult to understand and b) difficult to modify and maintain. The steps involved in leading to the best possible solution to a problem include:

1) Identifying the problem. The first step toward solving a problem is to identify the problem. In a classroom situation, most problems have been identified for you and given to you in the form of written assignments or problems out of a book. However, when you are doing problem solving outside of the classroom, you need to make sure you identify the problem before you start solving it. If you don't know what the problem is, you cannot solve it.

2) Understand the problem. You must understand what is involved in the problem before you can continue toward the solution. This includes understanding the knowledge base of the person or machine for whom you are solving the problem. If you are setting up a solution for a person, then you must know what that person knows. A different set of instructions might have to be used depending upon this knowledge base. When you are working with a computer, its knowledge base is the limited instructions the computer can understand in the particular language or application you are using to solve the problem. Knowing the knowledge base is very important since you cannot use any instructions outside of this base.

3) Identify alternative ways to solve the problem. This list should be as complete as possible. You might want to talk to other people to find other solutions than those you have identified. All alternative solutions must be acceptable ones.

4) Select the best way to solve the problem from the