1. 2016
By: ENGR MUNIR AHMED MAHAR
According to new pattern of Karachi intermediate board of education. This notes are
divided into C language Programming And Database with Ms-Access
2. C
C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972 by
Dennis Ritchie.
C is a computer Programming language that means that you can use c to create lists of
instruction for a computer to follow c is one of thousands of programming languages currently
in use c has been around for several decades and has won widespread acceptation because it
gives programmers maximum control and efficiency. C is an easy to learn it is a bit more
cryptic in its style than some other languages, but get beyond that fairly quickly.
FEATURES OF C LANGUAGE:
C is a case sensitive language
C is a collection of libraries
Libraries is a collection of Functions
Function is a collection of Statements
Statements is a collection of Collectors
C language can Support IDE “Integrated Development Envorment”
C language can support only Compiler Translators
A C file Must Be .cpp (C plus plus)
C Keywords
Keywords are the words whose meaning has already been explained to the C compiler (or
in a broad sense to the computer). The keywords cannot be used as variable names
because if we do so we are trying to assign a new meaning to the keyword, which is not
allowed by the computer. Some C compilers allow you to construct variable names that
exactly resemble the keywords. However, it would be safer not to mix up the variable
names and the keywords. The keywords are also called ‘Reserved words’.
IDE:
IDE abbreviate as “Integrated development envorment”. It is a platform that we can type
any c program, compile, execution and display of results. IDE is a programming envorment
that typically consist of code editor, a compiler, a debug and graphical user interface
(GUI). The IDE is May stay alone application or may be included as a part of computer
program. IDE is and interface between user and computer that perform simultaneously.
COMMON EXAMPLE: GW-Basic, Visual Basic, C Language etc
4. Q: Define Header Files?
HEADER FILES:
DEFINATION:
Header file is a collection of function that found in different libraries. A header file is
always define in the top of program and found in include directory. The header files are
always assigned with sign of #. An every header file contains different functions like
<math.h> library is containing of different mathematical functions.
Q: How Many Files to generate a compiler after the execution of C Program?
C FILES:
There are four files to generate a compiler
automatically 1. .Cpp
2. .Bak
3. .Obj
4. .Exe
.CPP
The .Cpp is a source file that based on a c programming code without this file we cannot
maintain other files the extension of .cpp is recognize as c plus plus code
.BAK
The backup file is automatically generated file that provide backup of source code suppose
the source file is deleted we can use backup file as a source code but it necessary to
rename the extension of file as .cpp
.OBJ
The .obj is object oriented file that contain a machine code and store errors, values, and
result oriented machine code without the object file the source program cannot entertain.
.EXE (Executable File)
The Executable file is run without any support of program sometimes it called compiled
file so the .exe file is a powerful extension that execute computer programs and there is
no need to install any computer program
6. Q: What are Format Specifies?
FORMAT SPECIFERS
A format Specifers are used to convert the particular data. A format specifer program
very important rule because when we store the data in the computer memory. These
specifers can convert the data and display the accurate result.
Format Specifers Are:
SPECIFERS CONVERSATION
%c Single Character
%s String Data type
%d Integer data type
%f Float data type
%l Long data type
%fl Double data type
%x Hexadecimal data type
%o Octal Data type
8. Q: Define Gotoxy Statements?
Goto xy statements:
The goto xy statement is used to set the cursor on the screen and display text on the
particular column and row/line. There are 256 columns ( 0 to 255) and 25 rows (0 to 24).
SYNTEX: goto xy (C,R);
EXAMPLE:
Gotoxy(10,10);
Printf(“ YASIR “);
Q: Define Goto Statements?
GOTO STATEMENT:
The goto statement is a branching statement that we can move the cursor in the particular
line sometimes we can say it’s a conditional statement.
SYNTEX: goto c;
EXAMPLE:
Char
a=’B’; c:
printf(“ HI”);
getche();
goto c;
If no return statement found in function definition, the control automatically returns to
the calling of function. If a return value is not required, declare the function with the data
type of void otherwise to return the integer data type.
Q: Define Return Statements?
RETURN STATEMENT:
The calling of function. The return function is also used to return the value of
The return statement is used to terminate the execution of function and return to
calling of function.
SYNTEX: return expression
10. BREAK STATEMENT:
The break statement is used to terminate the nearest statement or do, for , switch-case
and while statement. The break statement is also perform in loops it mean we can
terminate in the mid of loop.
SYNTEX: break;
EXAMPLE:
Int a;
Printf(“1.Books
Name”); Printf(“ 2. Exit
“); Switch(no)
{
Case 1;
Printf(“ C language
“); Break;
Default:
Break;
Printf(“Wrong Entry”);
}
Q: Define Continue Statements?
CONTINUE STATEMENT:
The continue statement is used to pass the control of next iteration of the nearest do…
while, and for and by pass the remaining statements in the do, for, and while statement of
the body.
SYNTEX: continue;
The Continue statement is always perform when we cross of the body of the any loop and
moves the cursor or pointer in the next statement.
EXAMPLE:
void main (void)
{
clrscr();
int a;
for(a=1;a<=10;a++)
{
if(a==5)
continue;
printf("n %d",a);
12. Q: Define Variable And Its Types?
VARIABLES:
A variable is a name of value that store unique value. A variable is a collection of
characters normally in any language a variable can perform very important role that
capable to store values. A variable can identify by their names like a,b,c,x,y,z
RULES OF VARIABLES:
A Variable must be a character
We cannot define numeric number as a variable
We can assign variables as a character and numeric like A1,A2,A3
We can assign a variable 8 to 12 characters
Variable are not allowed to assign special symbols
Example a=10; b=’c’;
We Cannot allow duplicate values
TYPES OF VARIABLES:
1. Constant Variable or String Value
2. Numeric Variable
CONSTANT VARIABLES:
A constant is a collection of characters and character may be A to Z, a to z.. 0 to 9, &
$ The constant variable cannot change during the execution e.g b=’c’; z=55;
NUMERIC VARIABLES:
The numeric variable is use to store only numeric values e.g c=10(constant numeric value).
The variable may be change during the execution of computer program.
14. Q: What Are Data Types?
DATA TYPES:
Data types are use to store which type of data stored in the variables. Data types are
always identifying by their name, data types is a computer memory location that store
data. Data types are always define in the beginning of computer program. There are
various data types used in c language but major are,
INTEGER DATA TYPE:
Integer data type is use to store sure numeric value. Integer data type is capable to store -
32768 to 32767 and accommodate 4bytes
SYNTEX: int a;
CHARACTER DATA TYPE:
Character data type is always store string value and occupies 2 bytes and store 0 to 255 at
a time
SYNTEX: char a[30];
FLOAT DATA TYPE:
Float data type is used to store numeric value with decimal places. A floating data type
always reserved 4 bytes with the range of 0 to 2.4e
SYNTEX: float a=10.2;
15. FUNCTION:
One of the most fundamental ideas in problem solving is dividing a
problem into sub-problem and solving each problem independently c facilities his
approach through the use of function. A function is block off instruction that perform step
by step in the particular task. A function is also called “mini-program” and we can call one
or more times and execute bunch of series in a single statement. Every c program has at
least one function like main ( ) you can also write your own function and use them just as
you use functions a c library. When your programs starts main ( ) is called automatically
and it is always execute first.
FUNCTION PROTO TYPE:
DEFINATION:
A function proto-type is a way that declare any function using of function in any c program
that required some important rules the declaration of function is called “Function Proto-
Type”
It is a line written before main ( ) function the proto type tells the compiler in advance
about some characteristics of a function used in the program.
The Function proto-type is divided into three sections,
1. Data type of function
2. Name of Function
3. Arguments
DATA TYPE OF FUNCTION:
The data type of function is a type of function that return the value of data if function
does not return any value it mean the data type is void.
NAME OF FUNCTION:
The name of function is any # legal identifier that describes the name of function or calling
of function.
ARGUMNENTS:
The arguments coming inside the {} parenthesis and proceed by data types and other
function.
A function proto type is a definition of that required to the user. The arguments also
provide the data type and divided into commas.
17. INPUT AND OUTPUT FUNCTION:
There are many input & output functions use in c language but major
are Printf (), puts (), putchar (), scanf (), getche (), and gets ()
INPUT FUNCTION:
Scanf ( ) Function:
The scanf abbreviates as “Scan formatted input function”. This function is found in
<stdio.h> library. The scanf function is used to store the values during the execution of
program.
SYENTEX: scanf (“ %d ” , &a);
EXAMPLE:
Int a;
Printf (“Enter
No”); Scanf (“%d”,
&a); Clrscr();
Printf(“No is %d”,a);
Gets( ) Function:
The gets abbreviates as “Get String”. The get string is found in <string.h> library. The get
string function is simply responsible to store string type of data. A string is a collection of
character and character may be #, @, &, $ a to z, 0 to 9, A to Z so that’s why we cannot
use arithmetic operator in the string. The gets( ) function allows to store spaces during the
execution it mean we can write any name with spaces like ‘Yasir Khan’
SYNTEX: gets(variables);
EXAMPLE:
#include<string.h>
Char a[30];
Printf(“Enter Your Name:
“); Gets(a);
Printf(“Your name is %s “,a);
18. Getche( ) Function:
The getche abbreviates as “Get Character”. This function is simply responsible to store
single character and return particular value. This function is found in <stdio.h> library.
SYNTEX: a=getche( );
EXAMPLE:
Char a;
Printf(“enter character”);
A=getche( ) ;
Clrscr( );
Printf(“ the character is %c “ , a);
OUTPUT FUNCTION:
Printf () Function:
Printf abbreviate as “Print Formatted Output Function”. This Function is found in
<stdio.h> library.
This function is used to print any line or
statements. SYNTEX: printf (“Statement”);
EXAMPLE: printf (“ Hi “);
Puts () Function:
The function puts( ) stand for put string. Puts( ) is used to display string on the monitor.
This function is opposite of gets() function and this function is found in <string.h> library.
SYNTEX: puts(“String”);
EXAMPLE:
#include<string.h>
Clrscr();
Puts(“Welcome”);
Putchar () Function:
The function putchar() abbreviate as “Put Character”. Put character is used to store one
character at a time. The put character is a string function that’s why it can store only 1
character at a time it necessary to define the value in single ‘Quote’ like the variable A
store m value like a=’M’
SYNTEX: putchar (variable);
EXAMPLE:
char a;
a=’M’;
putchar(a);
20. LOOPS:
Definition:
A loop is way that execute block off code more than one times a block off code that
execute more than one time is called “LOOP”.
According to the c language a loop can be created to execute block off code for a fix
number of times, a loop can provide repeats of code in number of time but it depend on
test condition either condition is true or false.
There are three types of Loops in C language;
1. For Loop
2. While loop
3. Do…while loop
FOR LOOP:
Definition:
The for loop can execute a block off code for a fix or given number of
times. The for loop is divided into three sections
1. Initialize 2. Test 3. Increment
SYNTEX: For( initialize variable ; test condition ; increment )
EXAMPLE:
Int a;
For ( a=10 ; a<100 ; a+
+ ) Printf(“%d”,a);
Getch();s
1. INITIAILIZE:
In initialize section we will define variables and its value it mean a=1
2. TEST CONDITION:
In test condition we will define the test of condition either the condition is true of false
the for loop always execute block off code if the condition is true.
3. INCREAMENT:
In this section the increment operator increase value 1 by
1 For ( a=10 ; a<100 ; a++ )
22. WHILE LOOP:
DEFINATION:
The while loop is used to execute block off code as long as the condition is true. If the
condition is false from the starting the loop than block off code is not execute. The while
loop test the condition before its execution but sometimes the loop never be execute if
initial condition is not fulfill.
SYNTEX: While(test condition)
{
Block off
code }s
EXAMPLE:
Int a=1 ;
While(a<10)
{
Printf(“%d”,a)
; a++ ;
}
Do…WHILE LOOP:
DEFINATION:
The do..while loop is used to execute block off code as long as condition is satisfied. The
do…while loop execute block off code than test the condition. The deference between
while{} and do…while is that while{} loop test the condition before its execution but do…
while loop execute block off code than test the condition. The do…while os only loop that
execute block off code at least one’s time.
NOTE: After the Assigning of test condition it necessary to assign (;)
SYNTEX: Do
{
Block off code
}
While(test condition);
24. NESTED LOOPS:
STATEMENT:
A Nested Loop is a loop within I loop, an inner loop within the body of an outer one what
happens is that the first pass of the outer loop triggers the inner loop, which execute to
completion.
Nested loop divided into inner loop and outer loop
SYNTEX:
For( initialize variable ; test condition ; increment )
{
For( initialize variable ; test condition ; increment )
}
EXAMPLE:
Main()
{
Int a,b;
For(a=1;a<=10;a++)
{
For(b=1;b<=10;b++)
Printf(“%3d”,a*b);
Printf(“n”);
Getch()
}
}
26. Q: What are Control Structures?
CONTROL STRUCTURES:
In a computer program, control structure is used to control the execution of any
program. In a structure programming we can use limited number of structures.
There are three control structures in structures programming
1. Sequence structure or Sequential flow
2. Selection Structure or conditional structure
3. Iteration Structure or repetition structure
SEQUENCE STRUCTURES:
This is used to execute step by step line or statement in any computer program or execute
straight forward statement like in c language all commands are printf().scanf() are execute.
SELECTION STRUCTURES:
The selection structure is depend on one or more choices and we can select at least one at
a time some time it depend on the condition it mean the condition is true or false.
According to c language if-else, switch-case the both conditions are used to select any
value at a time.
ITERATION STRUCTURES:
The word ITERATION is referred to the loop it mean we can repeat of the code according
to the c language there are three loops for, while, do…while.
28. STRUCTURES OF C-PROGRAM:
/* Header Section */
Contain name, author, and revision number.
/*Include Section */
Contain #include statement
/*Constant and Type Section */
Contains types and #defines
/*Global Variables */
Any Global variable declare here
/*Function Section*/
Use Define functions
Main ()
{
}
HEADER SECTION:
In header section we can define the following name of program, purpose of program, and
description of program.
INCLUDE SECTION:
In include section we can define the following define two common libraries, special
libraries, <conio.h>, <stdio.h> and objects.
CONSTANT AND TYPE SECTION:
In constant and type section we can define constant variables and pre-define c.
GLOBAL SECTION:
In global section we can define global variables and global objects.
FUNCTION SECTION:
In function section we can define function that maintain whole program.
30. STRUCTURE PROGRAMMING:
Structured programming (sometimes known as modular programming) is a subset of
procedural programming that enforces a logical structure on the program being written to
make it more efficient and easier to understand and modify. Certain languages such as
Ada, Pascal, and Dbase are designed with features that encourage or enforce a logical
program structure.
Structure programming frequently employs a top-down design model in which developers
map out the overall program structure into separate subsections. A defined function or set
of similar functions is coded in a separate module or sub-module which means that code
can be loaded into memory more efficiently and that modules can be reused in other
program. After a module has been tested individually it is then integrated with their
modules into the overall program structure.
32. Q: Define Database?
DATABASE:
A Database is a collection of records and records is a collection of personal information.
A Database is collection of information that collect in different recourses a database is
very powerful tool that provides different applications or solutions a database system can
provide an organized system or data.
Q: Define DBMS?
DATABASE MANAGEMNET SYSTEM:
DBMS Abbreviate as “Data Base Management system”. Database management system is
software which provides help to the user. A database management system is a very
powerfull system that organizes good data base system. A DBMS is a collection of options
that helpful to organize or maintain any software.
DBMS software provides these options:
1. Search any record
2. Insert any record
3. Update Any Record
4. Edit Any Record
5. Delete Any Record
The DBMS is widely used in business applications. The database management system is a
set of software programs that control the organization, storage of data, and retrieve of the
records. The DBMS is a tool that user insert any request, the software fulfill the
requirement of the user and maintain the records.
33. 21 Prepared By: Muzmil Memon | email: 11it20@quest.edu.pk.
Q: Define SQL & its features?
STRUCTOR QUERY LANGUAGE:
SQL Stand for “Structure query language”, and pronounce as Sequel. A SQL is a query
language that is used to access the particular database and display the records on the
screen this language was devolved by IBM in the year of 1975. A SQL is a very famous
language that performs different commands like insert, delete.
FEATURES OF SQL:
SQL Allow accessing any database.
SQL can insert new records in database.
SQL can delete records in database.
SQL can update records in database
SQL is easy to learn.
SQL can execute Queries against a database.
SQL can support RDBMS.
SQL can retrieve data from a database.
34. DEFERENCE BETWEEN CONSTANT AND VARIABLE
CONSTANT VARIABLES
The Constant variables is assign the value in
the
The variable can store value during the
execution
program
The value is always fix The value may be change
We cannot input the value during the
execution We can input the value during the execution
The constant variable is divided into The variable divided into
1
. Numeric Constant
1
. Numeric Variable
2
. String Constant
2
. Constant Variable
Common Example Common Example
a=’A’; a=10; A=10; b;
DEFERENCE BETWEEN DBMS AND RDBMS
DBMS RDBMS
DBMS is stand for “Data base management RDBMS is stand for “Relational Database
System” Management System”
DBMS Cannot support SQL RDBMS Can Support SQL
In DBMS it’s difficult to add new fields In RDBMS we can easily to add new fields
In DBMS we can change one record to require a In RDBMS we can easily change the records
lot of time
It’s difficult to support Large Database We can easily maintain the large database
DEFERENCE BETWEEN IF…ELSE & SWITCH…CASE
Switch….Case If….Else
35. Switch Case is reserved words Switch…case is a
non-conditional statement We Cannot Use
Relational operator
We Can tested one or more values at a time
Switch…case
If..else is also reserved word If…else
is a conditional statement We Can
Use Relational Operator
We Can Compare two values at a time
If…else
28 Prepared By: Muzmil Memon | email: 11it20@quest.edu.pk.
36. DEFERENCE BETWEEN While, Do, For Loops
While Do…..while For
The while loop is used to
The do…while loop is used
to The for loop can execute
execute block off code as execute block off code as block off code for a fix
long as some condition will
long as condition is
satisfied number of times or given
true time
If the condition is false
from
The do..while can
execute For loop test the condition
the starting of block off
code
block off code at least
one’s and the condition is already
the block off code
cannot time either the condition is assign or given
execute true of false
The while loop test the The do..while loop test the The for loop execute block
conditi
on before
i
t
s condition after execution off statement in
give
n
executi
on number of times
The lop never be execute if The loop is execute if the The for loop can execute
initial condition will not
true condition is true or false
block off code but it
depend
or
match on the condition
While (TEST
CONDITION) Do
For(initialize
variables ; test
{ {
condition ;
increment)
Block off code Block off code
} {
While (test condition);
DEFERENCE BETWEEN GETCH & GETCHE
GETCH GETCHE
Getch abbreviate as “Get Character” Getche abbreviate as “Get Character” and e
for echo
Getch Can Store Any Character Getche Store Only Single Character
Cannot Return Values Always Return Values
We Can use as a input statement We Cannot use as a input statement