



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Basic concepts in C programming
Typology: Lecture notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




A program
This is a set of instructions written down and fed to the computer to help in solving a particular program.
Or
It’s a concise systematic step by step set of instructions that a computer obey in order to solve a given problem.
Programming
This is the development of a solution to an identified problem and setting up of related series of instructions which are then directed to a computer to produce desired results
Programming is the act of logical sequencing and assembling step by step set of instruction that a computer obey to solve a problem
Programming is divided into two categories
A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point, and in which control is passed downward through the structure without unconditional branches to higher levels of the structure.
Three types of control flow are used:
Examples of SP Languages
C, Pascal, COBOL, FORTRAN and Q-basic
Uses visual methodologies in creating programs hence referred to as event driven
OOP employ the use of objects (object is a self obtain thing)
Object is divided into classes OOP employ use of inheritance and polymorphism.
OOP language include:C++,Java,Visual basic,Delphi,Java script,Visual J++,Perl,PHP and Visual Fox pro
Difference
SP oop Path is more or less predefined Program is driven by events &executed by the user Programs are coded and driven Program is driven by event and executed by the user It employ the use of three control structures
Employ the use of objects
Why use C?
C was initially used for system development work, particularly the programs that make-up the
operating system. C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language. Some examples of the use of C might be −
Importance of ‘C’ language
C language is a famous programming language due to its qualities. Some qualities are:
Problem Solving includes
Basic structure of a structure program using sample program
Program sampe”Hello World”
#include <stdio.h>
int main() {
/* my first program in C */ printf("Hello, World! \n");
return 0; }
A C program basically consists of the following parts −
Let us take a look at the various parts of the above program −
A C program consists of various tokens and a token is a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens –
printf("Hello, World! \n");
The individual tokens are –
printf ( "Hello, World! \n" ) ;
In a C program, the semicolon is a statement terminator. That is, each individual statement must
be ended with a semicolon. It indicates the end of one logical entity.
Given below are two different statements −
printf("Hello, World! \n"); return 0;
Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminate with the characters */ as shown below −
/* my first program in C */
You cannot have comments within comments and they do not occur within a string or character literals.
A C identifier is a name used to identify a variable, function, or any other user-defined item. An
identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers. C is a case-
sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers −
mohd zara abc move_name a_ myname50 _temp j a23b9 retVal
The following list shows the reserved words in C. These reserved words may not be used as constants or variables or any other identifier names.
auto else long switch break enum register typedef case extern return union char float short unsigned const for signed void continue goto sizeof volatile default if static while do int struct _Packed double
A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it.
Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify