Lec01 Programming Fundamentals
Lec01 Programming Fundamentals
Fundamentals
Slide 1
Course Outline
Definition of Programming
History of Programming
Languages
Compiler & Interpreter
Definition of C language
Basic structure of C language
Header files
Void Functions
Data Types
Operators
Loop Structures
For Loop
While Loop
Do While Loop
Nested Loops
If Else Conditions
Nested If Conditions
Functions or Procedures
Switch-Case Statement
Local & Global Variables
Arrays
Course Outline
Multi-Dimensional Arrays
Strings
Functions of Strings
Pointers
Bitwise Operators
Structures
Introduction to OOPS
Definition of Programming
A precise sequence of steps to solve a
particular problem
OR
A vocabulary and set of grammatical rules
for instructing a computer to perform
specific tasks.
Introduction
-These instruction can be high level languages or low level
languages.
Introduction
Ca powerful computer programming language
thats appropriate for technically oriented people
with little or no programming experience, and for
experienced programmers to use in building
substantial information systems.
Youll write instructions commanding computers to
perform those kinds of tasks.
Moores Law
For many decades, hardware costs have fallen rapidly.
Every year or two, the capacities of computers have
approximately doubled inexpensively.
This trend often is called Moores Law, named for the
person who identified it in the 1960s, Gordon Moore, cofounder of Intel.
Moores Law and related observations apply especially to
the amount of memory that computers have for programs,
the amount of secondary storage (such as disk storage)
they have to hold programs and data over longer periods of
time, and their processor speedsthe speeds at which
computers execute their programs (i.e., do their work).
Similar growth has occurred in the communications field.
History of Programming
History:
In Programming, here we have four Generations
1st Generation: (Machine Dependent)
Machine languages (first-generation languages) are
the most basic type of computer languages,
consisting of strings of numbers the computer's
hardware can use.
History of Programming
2nd Generation: (Low Level Languages)
Assembly languages are only somewhat easier to
work with than machine languages.
developers use cryptic English-like phrases to
represent strings of numbers.
Assembler is used to translate the code into
object code.
History of Programming
3rd Generation: (Middle Level Languages)
These languages are machine independent.
Examples of 3rd Generation are:
FORTRON, COBOL, PASCAL, C, BASIC, etc.
Programming Languages
Programming Languages
Programming Languages
Programming Languages
Programming Languages
Programming Languages
Elements of a C Program
A C development environment includes
System libraries and headers: a set of standard libraries and their
header files. For example see /usr/include and glibc.
Application Source: application source and header files
Compiler: converts source to object code for a specific platform
Linker: resolves external references and produces the executable
module
Exercise# 01
#include <conio.h>
#include<stdio.h>
void main ( )
{
printf( Welcome to DIHE);
}
Comments
Text surrounded by /* and */ is ignored by computer
Used to describe program
#include <stdio.h>
Preprocessor directive
Tells computer to load contents of a certain file
<stdio.h> allows standard input/output operations
Example of C Program
/usr/include/stdio.h
/* comments */
#ifndef _STDIO_H
#define _STDIO_H
... definitions and protoypes
#endif
/usr/include/stdlib.h
/* prevents including file
* contents multiple
* times */
#ifndef _STDLIB_H
#define _STDLIB_H
... definitions and protoypes
#endif
The Preprocessors
The C preprocessor permits you to define simple
macros that are evaluated and expanded prior to
compilation.
Commands begin with a #. Abbreviated list:
#define : defines a macro
#undef : removes a macro definition
#include : insert text from file
#if : conditional based on value of expression
Data types
Variables
#include<conio.h>
main ( )
{
int x ;
int y ;
int z ;
x = 10 ;
y = 20 ;
z=x+y;
}
Scanf
Printf type
Input
Type signed int represented in base 10. Digits 0 through 9 and the sign (+ or -).
Type signed int. The base (radix) is dependent on the first two characters. If the
first character is a digit from 1 to 9, then it is base 10. If the first digit is a zero and
the second digit is a digit from 1 to 7, then it is base 8 (octal). If the first digit is a
zero and the second character is an x or X, then it is base 16 (hexadecimal).
Type unsigned int. The input must be in base 8 (octal). Digits 0 through 7 only.
Type unsigned int. The input must be in base 10 (decimal). Digits 0 through 9 only.
x, X
Type unsigned int. The input must be in base 16 (hexadecimal). Digits 0 through 9
or A through Z or a through z. The characters 0x or 0X may be optionally prefixed to
the value.
e, E, f, g,
G
Type float. Begins with an optional sign. Then one or more digits, followed by an
optional decimal-point and decimal value. Finally ended with an optional signed
exponent value designated with an e or E.
scanf(%d,&x)
printf(%d,x)
THANK YOU