You are on page 1of 20

Introduction

to
C
Programming
• C is a programming language
developed at AT & T’s Bell
Laboratories of USA in 1972.
• It was designed and written by a
man named Dennis Ritchie.
• Initially designed for programming
UNIX operating system.
• Device driver programs ,Software
tool and compiler is written in C.
C has now become a widely used professional
language for various reasons:

➢ Easy to learn
➢ Structured language
➢ It produces efficient programs
➢ It can handle low-level activities
➢ It can be compiled on a variety of computer platforms
Program
• Environment Setup
(a) Text Editor
(b) The C Compiler.

Text Editor
• Used type your program.
• Examples : Windows Notepad, OS Edit command, Brief, Epsilon,
EMACS, and vim or vi.
• The files you create with your editor are called
the source files and they contain the program source codes.
• The source files for C programs are typically named with the
extension ".c".
The C Compiler
• The source code written in source file is the human readable
source for your program.
• It needs to be "compiled" into machine language so that your
CPU can actually execute the program as per the instructions
given.
• The compiler compiles the source codes into final executable
programs.
• The most frequently used and free available compiler is the
GNU C/C++ compiler.
Testing is the process using Debugging is the process
which we find errors and using which we correct the
bugs. bugs that we found during the
testing process.
Testing can be manual or
Debugging is always manual.
automated.
Debugging can’t be automated.
What is algorithm?
• An algorithm is a procedure or step-by-step instruction for solving a
problem.
• They form the foundation of writing a program.
• For writing any programs, the following has to be known:
• Input
• Tasks to be preformed
• Output expected
•An algorithm is a set of commands that must be followed for a
computer to perform calculations or other problem-solving
operations.

•According to its formal definition, an algorithm is a finite set


of instructions carried out in a specific order to perform a
particular task.

•It is not the entire program or code; it is simple logic to a


problem represented as an informal description in the form
of a flowchart or pseudocode.
Flowcharts
• A flowchart is a diagram that
depicts a process, system or
computer algorithm.

• They are widely used in multiple fields


to document, study, plan, improve and
communicate often complex processes in clear,
easy-to-understand diagrams
Terminal/Terminator Input/Output Decision

Predefined process Process Comment or Annotation

Document Stored Data Flow Arrow

On-page connector/reference Off-page connector/reference


Example :
More Examples
• https://engineerstutor.com/2018/08/27/examples-of-algorithms-and-
flow-charts-with-c-code/
The C Character Set
• Alphabet : A, ….., Y, Z
a, b, ……, y, z Char
• Digits : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 int
• Decimals: 1.2 ,3.4,4.6.0.23,0.001 float
• Special symbols :~ ‘ ! @ # % ^ &
() {}[]:;"'<>,.?/ Operator
% ! / - + * <= >
First C program
Preprocessor Directive
#include<stdio.h> Header File: Standard input Output File
#incude<conio.h> Console input Output File
void main()
{
Printf(“Hello World”);
getch(); waits for any input from the keyboard
return 0; Terminates C program
}
Printf() and scanf()
• General form of printf( ) function is,

printf ( "<format string>", <list of variables> ) ;

%f = printing real values


%d = printing integer values
%c = printing character values
\n = new line
\t = tab
Scanf()
• & is an ‘Address of’ operator.
• It gives the location number used by the variable
in memory.

• Ex: &a
• scanf( ) at which memory location should it
store the value supplied by the user from the
keyboard
#include<stdio.h>
#include<conio.h>
void main()
{
int x;
clrscr();
printf("Enter a number:");
scanf("%d",&x);
printf("Entered Number x=%d",x);
getch();
}

You might also like