TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 4 May 2020

Literals In C Language | Literals In C Language In Hindi

Literals In C Language


Literals are the constant values assigned to the constant variables. We can say that the literals represent the fixed values that cannot be modified.

 It also contains memory but does not have references as variables.

 For example, const int =10; is a constant integer expression in which 10 is an integer literal.

download image of literal in c

Fig: Literals In C 

Types of literals

There are four types of literals that exist in C Program:

  • Integer literal
  • Float literal
  • Character literal
  • String literal


1.    nteger literal

It is a numeric literal that represents only integer type values. It represents the value neither in fractional nor exponential part.

Program Of Integer Literal

       #include <stdio.h>  
      int main()  
     {  
    const int a=23;  // constant integer literal  
    printf("Integer literal : %d", a);  
    return 0;  
    }  

Output

Integer literal : 23

2.Float literal

It is a literal that contains only floating-point values or real numbers. These real numbers contain the number of parts such as integer part, real part, exponential part, and fractional part. The floating-point literal must be specified either in decimal or in exponential form. Let's understand these forms in brief.

Examples of float literal in decimal form are:


       1.2, +9.0, -4.5  

Program Of Float Literal


            #include <stdio.h>  
       int main()  
          {  
    const float a=4.5; // constant float literal  
    const float b=5.6; // constant float literal  
    float sum;  
    sum=a+b;  
    printf("%f", sum);  
    return 0;  
       }  

Output

10.100000


3.Character literal

A character literal contains a single character enclosed within single quotes. If multiple characters are assigned to the variable, then we need to create a character array. If we try to store more than one character in a variable, then the warning of a multi-character character constant will be generated.


Program Of Character Literal

    #include <stdio.h>  
    int main()  
{  
    const char c='ak';  
    printf("%c",c);  
    return 0;  
    }  
    

   4.String literal


A string literal represents multiple characters enclosed within double-quotes. It contains an additional character, i.e., '\0' (null character), which gets automatically inserted. This null character specifies the termination of the string. We can use the '+' symbol to concatenate two strings.

For example

String1= "dwivedicyber";
String2= "dairy";
To concatenate the above two strings, we use '+' operator:
“dwivedicyber”+”dairy”= dwivedicyberdairy

No comments:

Post a Comment