You are on page 1of 18

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name of the faculty : V.Rajendra Prasad.
Designation : Lecturer.
Branch : Computer Engineering
Institute : V.K.R & V.N.B Polytechnic Gudivada
Year/Semester : III Semester
Subject : UNIX & C
Subject Code : CM-304.
Topic : Understand repetitive structures.
Duration : 50 Min
Sub Topic : Null statement and Comma operator.
Teaching Aids : Diagram and animations, ppt.
CM304.54 1
Objective

On completion of this period, you would be able


know
 null statement and comma operator

CM304.54 2
comma operator and null statements

comma operator(,):

 The comma operator is used to separate


two expressions.

 The comma operator has lowest precedence of


all operators.

 the comma operator is used in for loop when there are


multiple expressions.

CM304.54 3
Example of comma operator
sum = (a=10, b=20, a+b);

 10 is assigned to variable a.
 20 is assigned to variable b.
 resultant value is a + b=30 is assigned to
variable sum

Note: Parentheses are necessary for using this


operator

CM304.54 4
Null statement

 null statement is always terminated by


semicolon.

 This is syntactically required but no action.

 The time delay loops use the null statements.

CM304.54 5
5
Example of null statement

{ for (i=1;i<=100;i++);}

 Here the loop is executed 100 times without


any output.
 Simply cause a time delay.
 The loop contains a semicolon known as the
null statement.

CM304.54 6
Summary

 Use and working of comma operator and null


statement with general form and with examples.

CM304.54 7
Quiz

1. Null statement is always terminated


by______?
b)Semicolon (;)
c) colon (:)
d)comma (,)

CM304.54 8
Quiz

1. Null statement always terminated


by______?
• Semicolon (;)
• colon (:)
• comma (,)

CM304.54 9
Quiz

2.What is the use of the null statement?


(a) used for time delay.
(b) using for special operation.
(c) None.

CM304.54 10
Quiz

2.What is the use of the null statement?


(a) used for time delay.
(b) using for special operation.
(c) None.

CM304.54 11
Quiz

3. What is the use of comma operator?


(a) Both a & b.
(b) To separate the two expressions.
(c) To combine the two expressions.

CM304.54 12
Quiz

3. What is the use of comma operator?


(a) Both a & b.
(b) To separate the two expressions.
(c) To combine the two expressions.

CM304.54 13
Quiz

4.What is the precedence of comma operator?


b)Highest precedence.
c) Lowest precedence of all operators.
d)No precedence.

C05/CM-304/54
CM304.54 14
Quiz

4.What is the precedence of comma operator?


• Highest precedence.
• Lowest precedence of all operators.
• No precedence.

C05/CM-304/54
CM304.54 15
Quiz

5. Which one is given time delay format?


(a) for (i=1;i<=1000; i++);
(b) for (i=0; i<1000;i++)
(c) for (i=1; i>1000;i++)

CM304.54 16
Quiz

5. Which one is given time delay format?


(a) for (i=1;i<=1000; i++);
(b) for (i=0; i<1000;i++)
(c) for (i=1; i>1000;i++)

CM304.54 17
Frequently Asked Questions

1. How comma operator are useful in ‘for’


statement?
2. Explain about null statement.

CM304.54 18

You might also like