Mistakes done by many beginners in C++ | Campus Placements | Special Lecture 1

  •  In this lecture explain you the important basics  and common mistakes  that are done by many beginners  in C++.
  • I'll assure you that after reading this, your coding skills will improve like anything .Because you won't repeat these mistakes in future . 

  • objectives

  1. Commenting lines
  2. Structure of C plus plus code for beginners
  3. Explanation of syntax 
  4. Different types of variable declarations
  5. Mistakes in these topics.
  6. Tips and a question 

  • Commenting lines
  • commenting lines is nothing but saying compiler to don't read particular lines
  • How this can be achieved ??
  • int a = 49;   //this is commenting line
  • For example see here above blue line is excluded from compiler execution but compiler will read int a = 49; .Because blue line is converted to comment with help of these two //
  • So guys whenever we keep // in front of a line ,then that line can be treated as comment. And it has no use for compiler
  • Then why these are in coding without any use??
  • Hey I said they are not useful for compiler only .
  • They are very much useful to us.
  • They are used to mention why a coding line is used for?
  • Confused??
  • Don't worry I'll explain.
  • In future you will went into a software company and wrote a 10000 lines of code. After some days ,one  of your team mate opens your code to use it .He will be confused to see the code because it is huge. Now these commenting lines helps him to read code easily. So we should learn them .
  • How to comment multiple lines???
  • We can use /* multiple lines and */,here you can observe.
  • int rsult = 56; /*this is syntax for commenting multiple lines you can observe till we use another star slash everything comes under commenting and these blues lines are excluded by compiler*/.

  • Structure of C++ code
  • Total code in c++ can be divided into two parts for beginners .
  • One is the int main() and another is outside int main()
  • int main() acts like a main gate to the compiler.
  • For example if someone want to go into a house  .They must and should go through the main gate of house.
  • Similarly our compiler also stars executing/runs code from int main
  • int main has body in which we write statements
  • What are statements??
  • statements are nothing but a line of code
  • For example : int a = 20;cout<<"code with dare"; etc.,
  • second part - Out side the int main()
  • This part is always used for the reference purposes to int main()
  • For example #include<iostream> ,#include<bits/stdc++.h> ie., all header files and standard definitions are located here
  • Don't worry ,you will learn all standard definition in future lectures

  • Syntax

  • Guys the main important thing that you should remember is ,that you have to end single line statements with a semi-colon
  • For example 
  • We write 
    •  int a = 0;
    •  cout<<a;
    •  a= a+ 7;
  • thus we use semi colon at end of statements.

  • Different types of variable declarations
  • Guys we should declare a variable only one time
  • For example if we declare like this
    • int first = 20;
    • We should not declare again like float first = 3.56;
  • we can declare variable in in two types;
    • int man_weight = 65;
    •  or 
    • int man_weight ; 
    • man_weight = 65;
  • thus we an assign a value to variable at the time of declaration or we can assign value later.

  • Common Mistakes
  •  Many people will forgot to keep semicolon at end of statements
  • Also many people will use same variable name , to declare another variable 
  •  we cannot declare another with first as variable name
  •  like char first ='c' or float first = 5; this will give us errors.
  • Tips & question
  • Guys always use meaning full names for variables  because many companies likes this way while your interview
  • Because if you use meaningful names ,then  you won't repeat the same name to declare another also it will be more understanding  and also helps other to understand easily
  • for example
    •  int total_score = 52;
    •  int nmsf = 52;
  • It better to see total_score instead of this nmsf 
  • Guys also make a habit of commenting you code like this which helps others to read your code in future 
  • question 
  • Which symbols are used in commenting multiple lines
  •  a.   /+            b .   %/             c .  /*                d . //
  • Hey do comment your answer for above question you can also have effective and great video explanation with compilation of codes .Also you can have another  question which improves you learning

Don't worry guys if you are still confused you will know everything in further concepts ,
Don't give up  .Don't Panic  we will learn everything in future lectures



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