Tuesday, 12 February 2013

Introduction to C Programming

Problem Solving Through ‘C’

Learning ‘C’ Programming

  • —Syntax
  • —Semantics
  • —Solving

Block Diagram of Computer


Characteristics

  1. —It works on stored program concept
  2. For problem solving computer is used

  • —      Automation
  •       Handle large volume of data
  • —      Speed
  • —     Accuracy 

Types of Real World Problems

—In real world applications we come across day to day problems


  • Going to market for shop
  • —Solving quadratic equations
  • —Matrix Operation: Add, Multiply…
  • —ATM
  • —Grade calculation
  • —Railway/Flight Reservation
  • —Library Automation
  • —Many More.....

Approach to Problem Solving


  • Define and Identify the Problem
  • —Analyze the Problem
  • —Identifying Possible Solutions
  • —Selecting the Best Solutions
  • —Specifications
  • —Algorithm
  • —Coding
  • —Testing
  • —Maintenance

Algorithm/Flowchart:


  • An algorithm is a sequence of instructions often used for solving problem
  • —A flowchart is a schematic representation of an algorithm 

Coding:

  • Set of instructions for solving a problem

—Testing:

  • —Finding the errors in the code for possible values
  • —Like taking a=0 gives unambiguous results

Maintenance:

  • —Modification due to requirements change
  • —Scalability

Introduction to Algorithms


  • Step by step method to solve a problem
  • —Must include ALL required information

Flowcharts






More About High Level Languages


  • —The languages are designed keeping in mind features of portability
  • —The languages are machine independent
  • —Easy to write and understand
  • —The programmer pays whole attention logic of the program

Translators

For translating high level and low level language to machine language

  • —Assembler:  Assembly Level -->   Machine Level
  • —Interpreter

  1. —High Level --> Machine Level
  2. —Interpreter searches the error statement by statement

  • Compiler

  1. —High Level   --> Machine Level
  2. —Compiler searches all errors in the code and lists them

Some High Level Languages

  • —BASIC
  • —FORTRAN
  • —PASCAL
  • —COBOL
  • —C
  • —C++
  • —Java

C

  • Developed at AT&T Laboratory of USA
  • —Year: 1970
  • —Created By: Dennis Ritchie

Why C?

  • A basic foundation for learning programming language elements
  • —Major parts of popular OS like windows, Linux, Unix are written in C
  • —Embedded System Programs are written in C
  1. Microwave Oven
  2. —Washing machines
  3. —Digital Cameras

  • C provides several language elements that makes interaction with hardware
  • —Several Gaming programs are also developed in C





Compiling C Program - Linux

—Writing the code

  • —vi hello.c
  • —insert data (i)
  • —save changes (Keys: esc:wq)

cc hello.c

The compiler generates an executable

  • —a.out

Type ./a.out

Output

  • Hello World


See You..in The next Post with very basic of C Programming









No comments:

Post a Comment

String functions

Read This: strncpy() strncat() strstr () strlen() — Predefined function defined in string.h . — — Returns the len...