Variables and Constants in C++ | Coding for beginners | Lecture 2

 


  • What are variables ??

  • Variables are important basic elements in coding .
  • These are used to store values like numbers , alphabets , sentences etc.,
  • For eg.,  int x = 32 ; Here x acts as variable because it is storing number 32 .Don't confuse about "int" you will get clarity about it before you complete this lecture 2. 
  • Why and where these variables are used ??
    • These variables are used everywhere in coding like solving an arthematic expression like .,
    • Let  one variable a = 2 ,and another variable  b = 3 now if c = a+ b then c = 5.
  • Why these are called as variables ??
    • Because the answer is in their name ie., we can change the value stored in a variable in coding 
    • For eg., a = 2 , we can also store 3 in a by saying a = 3,now a is changed to 3, therefore a = 3.

*****Don't worry if you are confused you will know everything in further concepts ,Don't give up if you are confused . Don't Panic ,be patient we will learn everything*****

  • What are constants ??

  • There is a small difference between variables and constants 
  • We cannot change the value in constant once it is stored .
  • For eg., const int x = 35; Here x acts as constant because it is storing number 35 which cannot be removed or changed .Don't confuse about "const" you will get clarity about it before you complete this lecture 2. 
  • Let  one variable a = 2 ,and another variable  b = 3 now if c = a+ b then it won't say c = 5 like before ,it will give error because now c is constant.
  • Now you will get answers for your doubts what is "int" and "const" .
  • In above concepts you have seen x,a,b,c, are storing some values .These x,a,b,c are called as identifiers.
  • What are identifiers??
  • These int , const helps to convert identifiers int variables , constants respectively .
  • These int, const are called as keywords .

  • Keywords

  • Finally we can say keywords are used to convert identifiers 
  • There are many keywords like int ,const ,char ,float ,etc.,
  • By keeping these keywords infront of identifiers we can use them
  • float  n  =   25.12 ;   ---eq.1
  • In above eq.1 => float is keyword , n is identifier , 25.12 is value 

  • Types of keywords

  • int : This keyword is used only to store integers like 5, 25 ,69 etc., but not decimals like 56.2,96.3 etc.,
    • eg .,  int aa = 33;
    •          int g = 56;
    •          int num = 7;
    • here aa,g,num are identifiers
  • float : This keyword is used only to store integers like 5, 25 ,69 etc.,
    • eg .,  float ab = 3.33;
    •          float h = 56.53;
    •          float kum = 0.7;
    • here ab,h,kum are identifiers
  • char :  This keyword is used only to store alphabets or special charecters like 'p' ,'A' ,'+' ,'$','g'.
    • eg .,  char dd = 'Q';
    •          char l = 'j';
    •          char bum ='+';
    • here ab,h,kum are identifiers
    • using of ' ' is must for char  
  • I think you can guess the use of const keyword.

  • This is all you needed currently to move to next lectures 
  • I'll introduce remaining keywords in future lectures
  • Guys here I'll upload this video don't panic with other things i told you I'll say about them in future ,this is just a sample video which helps understand better👀
    


👉👉👉What is #include<bits/stdc++.h>

*****Don't worry if you are confused you will know everything in further concepts ,Don't give up if you are confused . Don't Panic ,be patient we will learn everything*****

***** If you have any doubts please ask in comment box*****

Guys if you have any doubts, please let me know

Post a Comment (0)
Previous Post Next Post

How to start Coding | coding for beginners | Lecture 1