Day 3 : Variable and Data types in the C language.

Day 3 : Variable and Data types in the C language.


In last session we discuss about below points.


1. What is Comments in c lang?

Commenting in c lang




we have mainly two types of commenting in c language.


   a.Single line comment


    Single line comments are represented by "//".

    single line comments are used to comments single line in c language.


   b.Multi line comments 


   Multiline comments are represented by "/* ----------*/".

  Multiline commenting are used to comments more than one line in c language.

 

2. Datatypes & identifiers in c lang?

Variables & Data types in c language






Datatypes are data represented in c language for different values in c lang . Identifiers .

3. Keywords in c lang


Keywords are reserved keyword in c lang .

4. What is white space in  c-lang?


white space is ignored by c lang compilar.

5. Input And Output Functions in c lang?


    Input Functions :

      Input Functions are functions in which user can input value.
     
    Output Functions: 

     Output Functions are functions in which we can print our output value in our compiler.



Please Read Privious Chapter In c-lang: Day 2 : Structure of c and Input , Output in c programming

 

***********Varibales & Datatypes in c*************


What is variables in c lang?


variable declaration is important for print values or more complex equations.

variable is only name for storage are that our programe can set.


What are the laws in c lang for variable declaration?

  • we can not use keyword(reserve keywords) as variable name;
  • can containt alphabets, digits, underscore. 
  • can't start with a digit. /// int One  
  •  white space and rezerved keyword is not allowed.

Valid Example for variable declaration:  


  int one = 1;

char one = 'a';


Invalid Example for variable declaration: 


int 121one = 1;

char 1 = 'a';


//Single character declaration in c


char name = 's';


//string declaration in c


char name[] = "Learn";


//intiger declaration


int name = 12;


//floting value declaration


float name = 10.50;



Datatypes in c language 


datatypes specifies the size & type of value that can be stored as an variable.


1) Basic Data type

  •    int   = { 2 byte & -32768 to 32767}
  •   char  = { 1 byte & -128 to 127} 
  •   float = { 4 byte & }
  •    double = { 8 byte }
// we Can cheack sizes of data type in c lang with sizeof function .


Small assignment  for everybody: Print Size of int , char , float in dev C++;


2) Derived Data type //depending upon project

  •    Array
  •    Pointer
  •    structure
  •    union


3) Enumeration Data type: enum


4) Void Data type: void  // empty


More information for c lang


  • Datatype size by 32 bit architecture
  • find size of data type in your programm with 
  • printf(" size of int :%d" , sizeof(int));
  • data types consume memory / ram of from your system.
  • Example with 4 gb ram
  • -----> bits to Gb conversion


 Assaignment of the day?

  • Program 1: WAP to display first name, middle name, last name and scored marks, grades of candidates who participated in a quiz competition using formatted output.
  • Program 2: WAP to display the list of at least 5 fruits and their quantities with unit price.
  • Program 3. WAP to display name of your friend, date of birth and city, where output should be formatted properly
  • Program 4. WAP to  display the well formatted output to list the order details contains order id, order date, customer name, contact no, due amount



Post a Comment

Previous Post Next Post