User:Saikiaarabinda



GCC Compiler

Compile

=UNIT 1 BASICS OF C PROGRAMMING=

UNIT STRUCTURE

 * 1) Learning objectives
 * 2) Introduction
 * 3) Basic Definition
 * 4) Pseudo Code
 * 5) Algorithm
 * 6) Flowchart
 * 7) Program
 * 8) The C language
 * 9) Getting Started with C
 * 10) Elementary Data type
 * 11) C Character Set
 * 12) Identifier
 * 13) Variable
 * 14) Constant
 * 15) Reserved word
 * 16) Symbolic Constant
 * 17) Let us Sum Up
 * 18) Answers To Check Your Progress
 * 19) Further Readings
 * 20) Possible Questions


 * 1) LEARNING OBJECTIVE

After going through this unit, you will be able to


 * Define basic Structure of computer programming
 * Identify elements of C language
 * Know about General Structure of C program
 * Compile and Execute a C program
 * Declare and initialize variable
 * Identify C’s keyword and character set


 * 1) INTRODUCTION

Suppose you planned to construct a house. And go to an architect. You explain the requirements to architect such as number of drawing room, in which side the kitchen will be placed, how the front side will be look like etc. Depending on your requirement and testing result of soil and environment, architect will design a house by paper and pencil and submit to you. And you start to lay the first stone. After some days your house will be completed. This is the more general way to build a house. Now what is the relation of building a house with program? Let me map you the concept of building a house with programming construct. Suppose your program is to build a house. Input: Money and requirement and output will a beautiful hose. First you planned about a house; this (thought) is the logic of the program in programming construct. Next you go to an architect and explain your requirement, this is the pseudo code of you program. Depending on your pseudo code the architect draws a design and submits to you, this is the flowchart of your house. After step by step execution that is from laying the first stone to the roof one day you house will be completed. This is the program. And now you are enjoying with the output of the program.

The programming logic, pseudo code / algorithm and flowchart are the basics for every programmer. The following section will explain you the concept.

1.3.1  Pseudo Code

The name implies that, it is the codes, which are pseudo (false). Or you can define Pseudo code as a compact and informal high level description of a solution (of a computer problem), that uses the structural convention of programming language but omits detailed language specific syntax. Pseudo code generally consists of short English phrases to express a specific task. But interestingly there are no specific rules to write pseudo code. Then why we need pseudo code?

Implementing a problem with proper symbol and syntax is a complicated job. To solve the complicated job, first we need the complete explanation of the job, and then we extract information from the explanation, and roughly design the solution, which will be relevant to a programming construct. This rough work will help, in designing the proper solution with proper symbol and syntax.

1.3.2  Algorithm

Algorithm is a sequence of instruction to solve a problem. Mind each term of the definition, the instructions are must be in sequence that is if you change the sequence of instruction then the algorithm might not give the desired result. After executing the instructions the desired result must be obtained. Another important thing to kept mind, when designing an algorithm is that each instruction must be sufficiently basic and carry out in a finite time. Now how do we design an algorithm? Let us take a problem –

Problem: Design an algorithm to add two integers and display the result.

Solution: First of all you need two integers. There are two ways to get the two integers. First you can supply the two integers from your side; secondly you can ask user to supply the integers. After getting the integers you store it into two containers. You need another container to store the sum of the two integers. You must initialize the third container as zero before you store the summation. Now perform the addition task and store the result into third container. Now display the content of the third container. This is the solution to your problem.

Step 1: Ask user to supply first integer. Step 2: Store the first integer into container A. Step 3:  Ask user to supply second integer. Step 4: Store the second integer into container B	Step 5:  Initialize container C as zero. Step 6: Add content of container A and B and store the result into container C. Step 7: Display the content of container C. Step 8: End.

1.3.3  Flowchart

A flowchart is a pictorial representation of an algorithm that uses boxes of different shapes to denote different types of instructions. A flowchart acts as a road map for a programmer and guide the programmer, how to go from the starting point to the final point while writing a computer program. A flow chart will also help you at the time of analyzing, debugging and testing your program. The main disadvantage of flowchart is that it is very time consuming and laborious to draw with proper symbol, especially for large complex program. The following symbols are generally used to represent an algorithm.