Escolar Documentos
Profissional Documentos
Cultura Documentos
USES OF C LANGUAGE
DISADVANTAGE OF C
LANGUAGE
Error-prone
Difficult to understand
Difficult to modify
HEADER FILES IN C
LANGUAGE
HEADER FILES
HEADER FILE
EXPLANATION
stdio.h
conio.h
string.h
math.h
Math functions:exp,sqrt,etc
ctype.h
Characters type:tolower,
etc.
stdint.h
Standard integer:int_n,etc
time.h
Time related
DATA TYPE IN C
LANGUAGE
In the c programming language, data
types refers to an extensive system
for declaring variables of different
types. The language itself provides
basic arithmetic types and syntax to
build array and compound types.
Several headers in the standard
library contain definitions of support
types, that have additional properties.
VARIABLES IN C
LANGUAGE
A variable is just a named area of storage
that can hold a single value (numeric or
character). The C language demands
that you declare the name of each
variable that you are going to use and its
type, or class, before you actually try to
do anything with it.
The Programming language C has two
main variable types Local Variables
Global Variables
LOCAL VARIABLES
GLOBAL VARIABLE
CONSTANT IN C
LANGUAGE
Constant value is the one
which does not change during
the execution of a program. C
supports several types of
constants.
A C constant is usually just
the written version of a
number.
REAL CONSTANTS
Real Constants consists of a fractional part in their representation.
Integer constants are inadequate to represent quantities that vary
continuously. These quantities are represented by numbers
containing fractional parts like 26.082.
Example of real constants are
0.0026
-0.97
435.29
+487.0
Real Numbers can also be represented by exponential notation.
'5'
'x'
';'
''
All character constants have an equivalent
integer value which are called ASCII
Values.
STRING CONSTANTS
A string constant is a set of
characters enclosed in double
quotation marks. The characters in a
string constant sequence may be a
alphabet, number, special character
and blank space. Example of string
constants are
"VISHAL"
"1234"
"God Bless"
"!.....?"
USE OF scanf
scanf() function is
used to read
character, string,
numeric data from
keyboard.
USE OF printf
printf() function is used to print the character,
string, float, integer, octal and hexadecimal values
onto the output screen.
We use printf() function with %d format specifier to
display the value of an integer variable.
Similarly %c is used to display character, %f for
float variable, %s for string variable, %lf for double
and %x for hexadecimal variable.
To generate a newline,we use \n in C printf()
statement.
Note:
ESCAPE SEQUENCE
LIST
PROGRAMMING LAYOUT
ALGORITHM
FLOWCHART
PROGRAM
COMMENTS
COMPILING AND
EXECUTION
ALGORITHM
A sequential solution of any
program that written in human
language,called algorithm.
Algorithm
FLOWCHART
A Flowchart is a type of diagram (graphical or symbolic)
that represents an algorithm or process. Each step in the
process is represented by a different symbol and
contains a short description of the process step. The
flow chartsymbols are linked together with arrows
showing the process flow direction. A flowchart typically
shows the flow of data in a process, detailing the
operations/steps in a
pictorial format which is easier to understand than
reading it in a textual format.
STAR
T
PROCESS
DECISION
CONNECTOR
INPUT/OUTPUT
PROGRAM
Ques-Write a program
to swap two variables
without using third
variable.
SOLUTION#include<stdio.h>
file
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(Enter value in a);
scanf(%d,&a);
printf( Enter value in b);
scanf( %d,&b);
a=a+b;
b=a-b;
a=a-b;
printf( \n After swapping a=%d, a);
printf( \n After swapping b=%d, b);
getch();
}
/* header
*/
/*variables*/
/*clearscreen*/
/*
statements
*/
COMMENTS IN C
A "comment" is a sequence of characters
beginning with a forward slash/asterisk
combination (/*) that is treated as a single
white-space character by the compiler and
is otherwise ignored. A comment can
include any combination of characters from
the representable character set, including
newline characters, but excluding the "end
comment" delimiter (*/). Comments can
occupy more than one line but cannot be
nested. The Microsoft compiler also
supports single-line comments preceded by
two forward slashes (//). These comments
cannot extend to a second line.