7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 1/27
CW E B I N A R
C O A C H I N G
B Y A P T U T S . C O M
E M A I L : L E A R N @ A P T U T S . C O M
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 2/27
ABOUT ME
• Bachelor's Degree in Computer Science Engineering
• Software Engineer in IT Industry & Teaching Experience
• 7 Years of IT experience in various technologies
• Expertise in C, C++, Application Development, Manual Testing, Web Automation
Automation Testing, Website Designing, PHP and VBScript
• Founder of LearnCOnline.com, LearnCPPOnline.com and Aptuts.com
• Contact Info: [email protected]
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 3/27
COURSE CURRICULUM
Following topics would be covered:
Overview
Fundamentals and Control Statements
Data Input and Output in C
Functions and Function Overloading
Arrays, Structures and Pointers
Strings and String handling functions
Storage Classes in C
Introduction to File Operations in C
The C Pre-processor Directives
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 4/27
OVERVIEW
C is a programming language developed by AT & T‟s Bell Laboratories of USA in 1972. It was desby a man named Dennis Ritchie. C is reliable, simple and easy to use. C has survived for more
Before starting with the programming, let‟s have a look at the C Character set.
Any alphabet, digit or special symbol can be termed as a character. Below are the list of valid alphsymbols allowed in C.
Alphabets:
A, B, C, D, … ,X, Y, Z
a, b, c, d, … ,x, y, z
Digits :
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Symbols :
~ „ ! @ # % ^ & * ( ) _ - + = | \ { } [ ] : ; " ' < > , . ? /
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 5/27
COMMENTS STATEMENTS
C supports two types of comments., // and /*...*/
Here, everything following // till the end of line is treated as comment.Usually /*..*/ style is used for commenting out of a block code, whereas, // is use
line comments.
Example of single-line comment:
// This is a single line comment
Example of multiple-line comment:
/*This is
a multiple line comment*/
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 6/27
IDENTIFIERS AND KEYWORDS
In a C program, every word is either classified as an identifier or a keyword
Identifiers, as the name suggests, are used to identify or name various proelements such as variables, constants, functions etc.
On the other hand, Keywords are a kind of reserved word which have sta
predefined meanings in C
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 7/27
IDENTIFIERS
As stated before, identifiers are names that are given to various program elements succonstants, functions, arrays etc. There are certain rules regarding identifier names in below:
1. Identifiers must consist of letters and digits, in any order, except that the first charletter
2. Both upper-case and lower-case letters are permitted
3. The underscore character (_) can also be included, and is considered to be a lette
4. An identifier should contain enough characters so that its meaning is readily appar
5. There are certain reserved words, called keywords, that have standard, predefinedThese keywords can be used only for their intended purpose. They cannot be useprogrammer-defined identifiers
6. It is required to note here that the keywords are all lower-case. Since upper-case acharacters are not equivalent, it is possible to utilize an upper-case keyword as an
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 8/27
EXAMPLES OF IDENTIFIERS
Examples of valid identifiers:
zx11
sum_1
_temperature
names
area
Examples of Invalid identifiers:7th
“a”
order-no
error flag
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 9/27
KEYWORDS
As stated before, keywords are the words whose meaning has already been explai
compiler (or in a broad sense to the computer). The keywords cannot be used anames because, if we do so, we are trying to assign a new meaning to the keywo
not allowed by the computer. The keywords are also called “Reserved words”.
Examples of Keywords in C:
and
orregister
char
int
float
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 10/27
DATA TYPES
Data types supported by C can be broadly divided into six heads as stated follows
1. int data-type2. char data-type
3. float data-type
4. double data-type
5. bool (boolean) data-type
6. enum (enumeration) data-type
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 11/27
DATA TYPES
int data-type:
int data-type represents the whole number (i.e., integer) quantities. Integers are required not to contain a decima
exponentchar data-type:
char data-type is used to represent individual characters. Hence, the char type generally requires only one byte of
float data-type:
float data-type (also called as floating point) represents values containing decimal places. A floating point value is dpresence of a decimal point. It is permissible to omit digits before the decimal point, or digits after the decimal popermissible to omit both.
double data-type:
double data-type is very similar to float data-type. It is used whenever the accuracy provided by a float variable is Variables declared to be of type float can store roughly twice as many significant digits as can a variable of type flo
bool (boolean) data-type:
This data type can take only two values true or false. It is commonly used to hold the results of comparisons
enum (enumeration) data-type:
An enumeration data type is an integral type that is defined by the user
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 12/27
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 13/27
OPERATORS AND EXPRESSIONS
An operator , in general, is a symbol that operates on a certain data-type. For eoperator + is the addition operator. It can operate on integer, character and real (flo
numbers.On the other hand, an expression is a combination of variables, constants and
written according to the syntax of the language.
Types of Operators:
1. Arithmetic operators
2. Unary operators
3. Increment and Decrement operators4. Relational operators
5. Logical operators
6. Assignment operators
7. Conditional operators
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 14/27
ARITHMETIC OPERATORS
There are five arithmetic operators. They are:
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Remainder after integer division (%). The % operator is also sometimes referred tthe modulus operator .
Example of the use of Arithmetic Operators:
Suppose that the x and y are integer variables whose values are 10 and 3 respectiarithmetic expressions involving these variables are shown below, together with tvalues:
x + y (Value: 13)
x – y (Value: 7)
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 15/27
UNARY OPERATORS
C includes a class of operators that act upon a single operand to produce a new v
operators are known as unary operators. Unary operators usually precede thoperands, through some unary operators are written after their operands.
Perhaps the most common unary operation is unary minus, where a numerical con
or expression is preceded by a minus sign.
Note that the unary operation is distinctly different from the arithmetic operator
subtraction (-) as the subtraction operator requires two operands.
Example:
-175, -root1, -(x+y) etc.
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 16/27
INCREMENT AND DECREMENT
These operators also fall under the broad category of unary operators but are q
than unary minus.
The increment and decrement operators are very useful in C language. They are ex
in for and while loops. The syntax of these operators is given below:
++<variable name>
<variable name>++
--<variable name>
<variable name>--
• The operator ++ adds 1 to the operand and -- subtracts 1 from the operand. Th
manifest in two forms: prefix and postfix.
• For example, the ++ operator can be used in two ways:
++m and m++
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 17/27
RELATIONAL OPERATORS
There are four relational operators. They are:
1. < (less than)2. > (greater than)
3. <= (less than or equal to)
4. >= (greater than or equal to)
Closely associated with the above mentioned relational operators are the followin
operators:
1. == (equal to)
2. != (not equal to)
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 18/27
RELATIONAL OPERATORS CONDT
These six operators are used to form logical expressions, which represent conditi
either true or false. The resulting expressions will be of type integer, since true i
in C by the integer value 1 and false by the value 0.
Example:
Suppose that a, b and c are integer variables whose values are 1, 2 and 3 respecti
logical expressions involving these variables are shown below:
a < b (True 1)
a == b (False 0)c!=2 (True 1)
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 19/27
LOGICAL OPERATORS
A logical operator is used to compare or evaluate logical and relational expressions. There are thoperators. They are:
An expression involving && or || is sometimes called compound expressions, since the expre
other expressions, that is, each of these operators (&& and ||) takes two expressions, one to tanother to the right.
Example of && operator:a > b && x == 10
The expression on the left is a > b and that on the right is x == 10. The above stated whole exprto true (1) only if both the expressions are true (i.e., if a is greater than b and the value of x i
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 20/27
LOGICAL OPERATORS CONDT
Example of ! operator:
The ! (NOT) operator takes single expression and evaluates to true (1) if the eis false (0), and evaluates to false (0) if the expression is true (1). In other wor
reverses the value of the expression.
For example, consider the following expression:
!(x >= y)
The expression after the ! operator is x >= y. The above not expression evaluat
if the value of x is neither greater than nor equal to y (i.e., only if x is less than y
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 21/27
ASSIGNMENT OPERATORS
There are several different assignment operators. All of them are used to form assignment exassign the value of an expression to an identifier.
The most commonly used assignment operator is =. Assignment expressions that make use of thwritten in the form:
identifier = expression
where,identifier generally represents a variable, andexpression represents a constant, a variable or a more complex expression
Example:
a = 3;
x = y;
sum = a + b;
In the above statements, the first assignment expression causes the integer value 3 to assigned toand the second assignment causes the value of variable yto be assigned to x. In the third assignthe value of the arithmetic expression is assigned to the variable sum i.e., the value of a + b is
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 22/27
ASSIGNMENT OPERATORS CON
Remember that the assignment operator = and the equality operator == are disdifferent. The assignment operator is used to assign a value to an identifier, wherea
operator is used to determine if two expressions have the same value.Also, C contains the following five additional assignment operators: +=, -=,*=, /=
how they are used, consider the first operator, +=.
The assignment expression:expression 1 += expression 2
is equivalent to:expression 1 = expression + expression 2
Similarly, the assignment expression:expression 1 -= expression 2
is equivalent to:expression 1 = expression - expression 2
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 23/27
CONDITIONAL OPERATOR
Simple conditional operations can be carried out with the conditional operator (? :). An expression the conditional operator is called a conditional expression. Such an expression can be written intraditional if - else statement.
A conditional expression is written in the form:expression 1 ? expression 2 : expression 3
While evaluating a conditional expression, expression 1 is evaluated first. If expression 1 is true (i.enon-zero), then expression 2 is evaluated and this becomes the value of the conditional expressiothe expression 1 is false (i.e., if its value is zero) then expression 3 is evaluated and this becomeconditional expression. Note that only one of the embedded expressions (either expression 2 orevaluated determining the value of a conditional expression.
Example:In the conditional expression below, assume that a is an integer variable:
z = (a < 0) ? 0 : 100;
In the above example, the expression (a < 0) is evaluated first. If it is true, the entire conditional expthe value 0. Otherwise (if the value is not less than 0), the entire conditional expression takes on th
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 24/27
OUTPUT
Output in C is enabled by the statement printf which is predefined to correspond
standard output stream.
Example of output statement in C:
printf (“Welcome to Aptuts.com”);
printf (“This is a number %d”, num);
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 25/27
INPUT
Contrary to printf, to receive input through the keyboard what is used is scanf
Example of using scanf:
scanf (“&d”, &num);
To enable the use printf and scanf, one needs to include a header file named stdio.
line of every program, by the statement:
#include <stdio.h>
This header file contains the declaration that are needed by printf & scanf stateme
this declaration, the compiler won't recognize printf & scanf.
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 26/27
WRITE FIRST PROGRAM IN C
Write a program in C that will accept two integer value from user and store it in a
named x and y. It should perform addition of two input values and the results sh
in a variable named z. At the end, it should display the result i.e. value of z on th
7/17/2019 Instructor Led C Online Webinar Session - 1.pdf
http://slidepdf.com/reader/full/instructor-led-c-online-webinar-session-1pdf 27/27
THANK YOU
Web: www.aptuts.com
Email: [email protected]
Social: www.facebook.com/aptuts