1.What is Constants ?

  • C Constants are also like normal variables. But, only difference is, their values can not be modified by the program once they are defined.
  • Constants refer to fixed values. They are also called as literals
  • Constants may be belonging to any of the data type.

Types of C constant:

  1.     Integer constants
  2.     Real or Floating point constants
  3.     Octal & Hexadecimal constants
  4.     Character constants
  5.     String constants
  6.     Backslash character constants

2.Diffrence Between real and inter constants.

Integer Constants

Real/float Constants

It must not have a decimal point. t must have a decimal point
The allowable range for integer constants is -32768 to 32767. Range of real constants expressed in exponential form is -3.4e38 to 3.4e38
The real constants could be written in one form. The real constants could be written in two forms—Fractional form and Exponential form.

 

3.Difference Between character and string in C.

Characters are simple alphabets such as a, b, c, d...., but with one exception. Any single-digit integer, such as 0, 1, 2, 3, 4,..., and special characters, such as $,%, +, -,*,..., etc., are similarly treated as characters in computer programming, and you can assign them to a character type variable by simply enclosing them in single quotes.

For example, we declare a character type variable ch and assign it the value 'a'.

char ch = 'a';

Strings are similar to sentences. They refer to a sequence of characters represented as a single data type. They're made up of a list of characters, which is actually an "array of characters." When passing information from the program to the user, strings come in quite handy.

Let’s see the following example to understand how to declare a string in C


/* String */
string str = "Ninjas";
    Promoted Topics
    PHP Force Source Code