 FLOW CHARTS
 PSEUDO CODE
 They are very precise. They represent our
thoughts exactly.
FUNDAMENTAL CONDITIONAL AND
CONTROL STRUCTURES:
Branching:
Two way branching:
Eg: if A > B, then Print A, otherwise
Print B
Multiway branching:
Eg: if n is 0, then Print ‘ zero’
1, then Print ‘ one’
2, then Print ‘ two’
3, then Print ‘ three’
ITERATION:
The third fundamental technique is
Iteration. It means repeating a set of
actions again and again.
 Pseudo code can be used to represent a
procedure for doing something.
 These are in between the English and the high
level computer languages.
The flow chart fundamental control structures
for branching and iteration correspond to the
following pseudo code.
 if…then…else
 if…then
 For…to…do…
 While…do…
Consider the statement:
number = number + 1;
The tokens are,
number - identifer
(variable)
= - operator
+ - operator
1 - constant
; - punctuation
A constant is of numeric or non-numeric type.
It can be a number, a character or a character
string that can be used as a value in a
program.
 Numeric constants are of three types:
• integer constant
• floating-point constant
• character constant
 A non-numeric data can be called as a literal.
String Literal:
A string literal or a string constant is
a sequence of characters from the system’s
character set, enclosed in double quotes.
 Integer Constant:
An integer constant is a decimal number
(base 10) that represents an integral value (the
whole number). It comprises of the
digits 0 to 9.
 Floating - point Constant
A floating-point constant is a signed real
number. It includes integer portion, a decimal
point, fractional portion and an exponent. Eg.
5.864E1
 Character Constant
A character is a letter, numeral or special symbol,
which can be handled by the computer system.
These available symbols define the system’s
character set.
Eg. ‘1’, ‘a’, ‘+’, and ‘-‘ are the valid character
constants.
 Identifiers are the names that are to be given to the variables, functions,
data types and labels in a program.
 The name of a variable can consist of alphabets (letters) and numbers.
 Other characters are not allowed in the name of a variable except an
underscore character.
 The variable name starts with an alphabet and its length may vary from one
character to 32 characters.
 The first character in a variable’s name should be an alphabet,
 Keywords (which have special meaning in C) cannot be used as identifiers
The valid variable names are:
 x
 length
 x_value
 y_value
 A123
POINTER VARIABLES
The variables in C are classified into ordinary
variables and pointer variables.
int x;
x = 10;
int *y;
A pointer variable assumes only address as its value. Each
variable takes some locations in the main memory according
to its type. Every location in the main memory is addressable.
y=&x;
• y represents the address of the variable x (&x)
• *y represents the value of the variable x (x)
UNARY
BINARY
TERNARY
Variable = Expression;
i++ postfix form
++i prefix form
c = a+b; arithmetic expression
c = a > b; relational expression
f = d = e; assignment expression
x = i++; /*postfix increment
expression on the right side*/
printf()
scanf()
 [ ] - represent array index
 { } - cover the body of the function
 ( ) - represent a function, to group items
 < > - enclose a header file in a preprocessor statement
 “ “ - represent string literals
 ‘ ‘ - represent a character constant
 /* */ - represent a comment
 ; - a statement terminator
 , - to separate items
KEYWORDS
They cannot be used as identifiers for the variables in a program.
auto break case char continue default
do else if float for int return static
switch while
A keyword must be specified precisely as given in the list.
 Each and every line of a C program can be
considered as a statement. There are
generally four types of statements. They are:
 • Preprocessor statement
 • Function header statement
 • Declaration statement
 • Executable statement
#include <stdio.h> => Preprocessor Statement
main() => Function header Statement
{
int a,b,c; => Variable declaration statement
int add(int,int); => Function declaration statement
a = 10; => Executable statement
}
PRINTF() STATEMENT:
PRINTF( FORMATTING STRING, CONTROL STRING)
printf(“%d”, n);
Formatting character Data type
%d int
%f float
%c char
%s char [ ]
%ld long int
%lf long float or double
control string of printf() function are:
‘n’ - new line character
‘t’ - tab character
‘b’ - backspace character
Eg: printf(“the value of i = %d n”, i);
 To read a value from the keyboard (standard
input), the function scanf() is used.
 The prototype of scanf() is similar to the
prototype of printf().
int x;
scanf(“%d”, &x);
• The second parameter of the above scanf()
function is &x, which represents the
address of x.
• & is the address of operator and when it is
being used with a variable, it provides the
address of that variable.
 The user or programmer can write functions to
define specific tasks that may be used at many
points in a program.
 The function which calls another function is
termed as calling function and the other is
termed as called function.
 A function declaration may be called
as a function prototype or a function model. The
function prototype has four components.
• Name of the function
• Return value type
• Number of parameters
• Type of each parameter
Function
protype
Function
definition
Storage
classes
auto
extern
register
static
if
• if(relational
expression)
• statement1
if..else
• if(relational
expression)
• statement1;
• else
• statement2;
switchcase
• switch(cond.expr.)
• {
• case1 expr1:
• ....
• break;
• case2 expr2:
• ....
• break;
• default:
• }
while do...while for
•
Initialization
while(condition)
{
……..;
processing stmts
…….;
increment
}
for(initialization;
condition;
increment)
{
body of the loop;
}
do
{
…….;
}
while(condition);
 DEFINITION:
An array is a collection of homogeneous elements
i.e. elements of similar data type.
 EXAMPLE:
int a[100];
 DECLARATION STMT:
int a[10]; /* => array declaration statement */
a[0]=6; a[1]= 7; …..a[99]=67;
A multidimensional
array has been
considered as an
array of
arrays in C language
DECLARATION
int a[3][3];
a[0] =[ 1 2 3 ]
a[1] =[ 4 5 6 ]
a[2] =[ 7 8 9 ]
 Structures are derived data types in C
language.
 Structures are used to create user-defined
types. Structures are commonly used to
define records to be stored in files.
 A file is a collection of records.
 A record is a collection of fields of
information.
 Roll number: an integer field
 Name: an array of characters
 age: an integer field
 Consider the following structure definition:
Eg:
struct student
{
int rollno;
char name[24];
init age;
} x, y;
Accessing the members of the
Structures:
x.rollno = 1000;
y.rollno = 1001;
Pointers to Structures:
struct student *ptr;
struct student s1;
ptr = &s1;
An Array of Structures:
struct student x[5];
x[0].rollno, x[0].name, uctures

Problem Solving Techniques

  • 1.
  • 2.
     They arevery precise. They represent our thoughts exactly.
  • 3.
    FUNDAMENTAL CONDITIONAL AND CONTROLSTRUCTURES: Branching: Two way branching: Eg: if A > B, then Print A, otherwise Print B Multiway branching: Eg: if n is 0, then Print ‘ zero’ 1, then Print ‘ one’ 2, then Print ‘ two’ 3, then Print ‘ three’
  • 4.
    ITERATION: The third fundamentaltechnique is Iteration. It means repeating a set of actions again and again.
  • 5.
     Pseudo codecan be used to represent a procedure for doing something.  These are in between the English and the high level computer languages. The flow chart fundamental control structures for branching and iteration correspond to the following pseudo code.  if…then…else  if…then  For…to…do…  While…do…
  • 8.
    Consider the statement: number= number + 1; The tokens are, number - identifer (variable) = - operator + - operator 1 - constant ; - punctuation
  • 9.
    A constant isof numeric or non-numeric type. It can be a number, a character or a character string that can be used as a value in a program.  Numeric constants are of three types: • integer constant • floating-point constant • character constant  A non-numeric data can be called as a literal. String Literal: A string literal or a string constant is a sequence of characters from the system’s character set, enclosed in double quotes.
  • 10.
     Integer Constant: Aninteger constant is a decimal number (base 10) that represents an integral value (the whole number). It comprises of the digits 0 to 9.  Floating - point Constant A floating-point constant is a signed real number. It includes integer portion, a decimal point, fractional portion and an exponent. Eg. 5.864E1  Character Constant A character is a letter, numeral or special symbol, which can be handled by the computer system. These available symbols define the system’s character set. Eg. ‘1’, ‘a’, ‘+’, and ‘-‘ are the valid character constants.
  • 11.
     Identifiers arethe names that are to be given to the variables, functions, data types and labels in a program.  The name of a variable can consist of alphabets (letters) and numbers.  Other characters are not allowed in the name of a variable except an underscore character.  The variable name starts with an alphabet and its length may vary from one character to 32 characters.  The first character in a variable’s name should be an alphabet,  Keywords (which have special meaning in C) cannot be used as identifiers The valid variable names are:  x  length  x_value  y_value  A123
  • 12.
    POINTER VARIABLES The variablesin C are classified into ordinary variables and pointer variables. int x; x = 10; int *y; A pointer variable assumes only address as its value. Each variable takes some locations in the main memory according to its type. Every location in the main memory is addressable. y=&x; • y represents the address of the variable x (&x) • *y represents the value of the variable x (x)
  • 13.
  • 14.
    Variable = Expression; i++postfix form ++i prefix form c = a+b; arithmetic expression c = a > b; relational expression f = d = e; assignment expression x = i++; /*postfix increment expression on the right side*/ printf() scanf()
  • 15.
     [ ]- represent array index  { } - cover the body of the function  ( ) - represent a function, to group items  < > - enclose a header file in a preprocessor statement  “ “ - represent string literals  ‘ ‘ - represent a character constant  /* */ - represent a comment  ; - a statement terminator  , - to separate items KEYWORDS They cannot be used as identifiers for the variables in a program. auto break case char continue default do else if float for int return static switch while A keyword must be specified precisely as given in the list.
  • 17.
     Each andevery line of a C program can be considered as a statement. There are generally four types of statements. They are:  • Preprocessor statement  • Function header statement  • Declaration statement  • Executable statement #include <stdio.h> => Preprocessor Statement main() => Function header Statement { int a,b,c; => Variable declaration statement int add(int,int); => Function declaration statement a = 10; => Executable statement }
  • 18.
    PRINTF() STATEMENT: PRINTF( FORMATTINGSTRING, CONTROL STRING) printf(“%d”, n); Formatting character Data type %d int %f float %c char %s char [ ] %ld long int %lf long float or double control string of printf() function are: ‘n’ - new line character ‘t’ - tab character ‘b’ - backspace character Eg: printf(“the value of i = %d n”, i);
  • 19.
     To reada value from the keyboard (standard input), the function scanf() is used.  The prototype of scanf() is similar to the prototype of printf(). int x; scanf(“%d”, &x); • The second parameter of the above scanf() function is &x, which represents the address of x. • & is the address of operator and when it is being used with a variable, it provides the address of that variable.
  • 20.
     The useror programmer can write functions to define specific tasks that may be used at many points in a program.  The function which calls another function is termed as calling function and the other is termed as called function.  A function declaration may be called as a function prototype or a function model. The function prototype has four components. • Name of the function • Return value type • Number of parameters • Type of each parameter
  • 21.
  • 22.
  • 23.
    if • if(relational expression) • statement1 if..else •if(relational expression) • statement1; • else • statement2; switchcase • switch(cond.expr.) • { • case1 expr1: • .... • break; • case2 expr2: • .... • break; • default: • }
  • 24.
    while do...while for • Initialization while(condition) { ……..; processingstmts …….; increment } for(initialization; condition; increment) { body of the loop; } do { …….; } while(condition);
  • 25.
     DEFINITION: An arrayis a collection of homogeneous elements i.e. elements of similar data type.  EXAMPLE: int a[100];  DECLARATION STMT: int a[10]; /* => array declaration statement */ a[0]=6; a[1]= 7; …..a[99]=67;
  • 26.
    A multidimensional array hasbeen considered as an array of arrays in C language DECLARATION int a[3][3]; a[0] =[ 1 2 3 ] a[1] =[ 4 5 6 ] a[2] =[ 7 8 9 ]
  • 27.
     Structures arederived data types in C language.  Structures are used to create user-defined types. Structures are commonly used to define records to be stored in files.  A file is a collection of records.  A record is a collection of fields of information.
  • 28.
     Roll number:an integer field  Name: an array of characters  age: an integer field  Consider the following structure definition: Eg: struct student { int rollno; char name[24]; init age; } x, y;
  • 29.
    Accessing the membersof the Structures: x.rollno = 1000; y.rollno = 1001; Pointers to Structures: struct student *ptr; struct student s1; ptr = &s1; An Array of Structures: struct student x[5]; x[0].rollno, x[0].name, uctures