Sunday, February 8, 2015

Constants in C

Constants:

A quantity whose value cant be changed during the execution of a program.

  e.g

  10,5.5,’a’ etc 
 Four Types of Constants:
1. Integer Constant
2.Floating point constant 
3.Character constant 
4.String Constant


Integer Constant:
 Numerical value without the decimal part.

  e.g

  562,2,-4,0
Floating point/Real constant:
Numerical values that have integral as well as decimal part.

  e.g

  -5.6,2.3,4.6,0.0 etc
 Character Constant:
  1. A single character enclosed in single quotation marks.

  2.Character can be alphabet, digit or special characters.

  e.g

  ‘s’,’b’,’+’,’1’,’$’,’&’
 String Constant:
A number of characters(alphabets, digits or special characters) enclosed in double quotation marks.

  e.g

  “Pakistan”, “Newyork”, “abc_123” etc

No comments:

Post a Comment