Professional Documents
Culture Documents
CSC 211 Lecture-1
CSC 211 Lecture-1
CSC 211 Lecture-1
Faculty of:
Computing
Department of
Computer Science
Course:
Computer Programming I (CSC-211)
Course Lecturer: Mr. AM Gimba
CSC 211-NAUB 1
Introduction to C Programming Language
A programming language is a formal language, which comprises a
set of instructions/commands that produce various kinds of output.
Programming languages are used in computer programming to
implement algorithms.
CSC 211-NAUB 2
C is a powerful and compact computer programming language that
allows you to write programs that specify exactly what you want
your computer to do. You’re in charge: you create a program,
which is just a set of instructions, and your computer will follow
them. Programming in C isn’t difficult, as you’re about to find out.
I’m going to teach you all the fundamentals of C programming in
an enjoyable and easy-to-understand way, and by the end of this
semester you’ll have written your first few C programs. It’s as easy
as that!
CSC 211-NAUB 3
Common Mistakes
CSC 211-NAUB 4
Compiler
The compiler can detect a wide range of errors that are due to
invalid or unrecognized program code, as well as structural errors.
CSC 211-NAUB 5
#include<stdio.h>
void main ()
this shows the start of the function, main body of the program
this opening brace indicates the start of the body of the main() function
The body of the function contains executable statements, each of which must be terminated
with a semicolon
this closing brace indicates the end of the body of the main() function.
CSC 211-NAUB 6
Keywords
Keywords are predefined, reserved words in C language and each of
which is associated with specific features. These words help us to use
the functionality of C language. They have special meaning to the
compilers.
There are total 32 keywords in C.
auto double int struct
do if static while
CSC 211-NAUB 8
Naming variables the name that you give to a variable,
conveniently referred to as a variable name, can be defined with
some flexibility. A variable name is a sequence of one or more
uppercase or lowercase letters, digits, and underscore characters
(_) that begins with a letter (incidentally, the underscore character
counts as a letter). Examples of legal variable names are as
follows:
CSC 211-NAUB 9
Examples of legal variable names are as follows:
firstname
gender
Monthly_Salary
Date_of_birth
_naub
Height
lenght
room1
room2
CSC 211-NAUB 10
Constants
CSC 211-NAUB 11
Literals
A literal is a value (or an identifier) whose value cannot be altered
in a program. For example: 1, 2.5, 'c' etc.
String Literals
A string literal is a sequence of characters enclosed in double-quote
marks. For example:
“good” //string constant
“” //null string constant
“ ” //string constant of white space
“x” //string constant having a single character
“Welcome to NAUB” //prints string with newline
CSC 211-NAUB 12
Identifier
CSC 211-NAUB 14
Identifiers are case-sensitive. For example name, Age is the
same as Age always, but age is not the same as Age, also
NUMBER is the same as NUMBER, But Number is not the same as
NUMBER.
CSC 211-NAUB 16
END
CSC 211-NAUB 17