A0

Labels

Showing posts with label c plus plus. Show all posts
Showing posts with label c plus plus. Show all posts

Operation of Hello World c++

 

[C++ is case sensitive language means if we will use upper case letter at the place of lower letter in the syntax then program will generate the error.] 

Here is the article related to c++ programming. Firstly we will check the simple Hello World program and then break that program into pieces and then check the every line and its use in the program

       
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World"<<endl;
return 0;

This is the program which will display the message "Hello World". Now we will break this program into pieces.

1) #include<iostream>

This is called header file in c++. We uses different kind of header files to access the different functionality of c++. This is like the key to access the treasure. In simple words if we want to access the specific file then we uses header file. In the above program I used iostream header file which is uses to take input or display the data or for basic functionalities such as to break line etc.


2) Using namespace std;

Actually the complete syntax of c++ is like

 "std::cout<<"Hello World"<<std::endl;"
 (in this way use std:: with every object used from specific header file)

 this syntax will become little bit difficult to implement therefore, we use using namespace std and this will automatically apply the std with every object of header file and in this way it will become more easy to use. 

Note:  

do you focus here at the end of the line I used a semi column(;) this we use to tell the compiler that we had end the line.


3) int main()

we can also use void at the place of int. Actually, we use main as a driver of the program like a car. Main should be compulsory in a program because without main program cannot run also every program always start from main. Moreover, this is more like a function which should be compulsory in a program. May be, in this stage you are not familiar with functions so, don't worry we will learn in our next lectures.

Note: After using int main() we will also define the scope for main by using the bracket({). If you don't know how to define the scope then answer is you can define scope like this { here you can write the program part}.

4) cout<<"Hello World"<<endl;

This is the main line to display the hello world as a output. Here I used cout and endl. cout is uses to display the data and after writing cout we need to use stream out operator(<<) and then use "Write string or message here" and then again stream out operator(<<) and then I used the endl to break the line. In this way I display the message as a output.


5) return 0;

We use return 0 when our main is of int type because int always return an integer at the end of the function. But if we will use void as the return type of main then it will return nothing at the end of the function.


In this way program works here. Now, you can try different experiments for this program to understand the behavior. 









How to develop logic?

 Logic Development

Have you heard programmer is nothing without logic? If yes then you should definitely read this article to which can help you in development of logics.

Before some practices we should understand what is logic? can you answer this question? you should answer if you don't know then don't worry I will answer you. "The ability to solve any problem". If you know better answer then you can comment below this will also increase my understand related to logics. So what ever, now I should come to point that how to develop logic?

logic development dowatse


How to develop

 Here please try to answer these questions.

1) How can you add 2 odd numbers to get even answer?

Answer:

Yes I know answer is too simple and definitely you had answered this question but I should also contribute my answer which is add 1+1 =2(odd +odd=even) . This is called logics and by solving these kinds of problems you can enhance you logics. Now try to solve question two.

2) Now try to solve by adding 3 odd numbers to get even answer?

Answer:
This is called logic now may be you are confuse here and may be your answer will be this is not possible but here I did not limit you, you can use any of the method to solve this question.

Hint: you can also use decimal numbers.

May be now you can solve this question. If not then don't worry I will tell you so the answer is 
5 + 3.9 + 1.1 =10 (odd + odd + odd= even).


Now, you had learnt the solution of another problem and do you know the meaning of it. Meaning of it, is you had develop your logic by solve these complex problems. Now you have to add this logic into programming (these are the sets of instructions which a machine follows to perform any task). If I will tell you to define that question 1 into the set of instructions. you can use any language to define instructions and at the same time I will also solve this question and answer is below

1) initialize three variables one for first number, second for second number and third for answer 
2) Now assign the first two variables with number
3) Now, add the first two variables and store the answer into third variable
4) Now you can display the answer.

I will solve this question in this way you can also use your own way to define instructions also you don't need to use the line of initialize or assigning because you don't know the meaning of it because now you are beginners. We will learn this in the next blogs.


Tips to improve Logic

1) Solve critical problems
2) try to solve same problem with different ways
3) Play logical games such as Castle Crash or Candy crash etc
4) Critical Programming practices is one of the best way to improve logics.


There are tons of others ways which can improve your logics but these are the only one's which are on my mind which I had shared.

Stay connected for more these kinds of articles.



 



Learn C++

 

Learn C++

We are starting the introduction of c ++ but before starting this we should talk about why we should learn c ++ as a first language. Mostly student ask this question, they thinks why c ++ and why not python because python is the most emerging language also easy to understand in the beginning but this is really an huge language we should not take start with it firstly we should develop some logic and we should understand how really programming works then we should shift to python. So whatever our question was why c ++? So answer for this question is c ++ is too old language also this language really tells the definition of the programming because in modern languages we don't need to initialize the variable or these kinds of things because scientists are trying to make the languages more simple to use therefore they are introducing the different libraries for the ease of the programmers therefore beginners can feel little bit difficulty to handle this because they cannot understand in more depth that how this program is really works. Therefore, c ++ providing the complete syntax for the programming. This was the first point that why we should learn the c ++ as a first language. Now the second point is c ++ is very powerful and very fast language because this is more close to the processor because c ++ directly access the Memory and this is the only one language which can access the Hardware directly this is the reason we use c ++ to develop game engines. If any person can get grip on this language then he can also earn a big amount of money by developing games or game engines. Mostly people thinks c++ is on the ending stage but reality is, It is an evergreen language because this is the fastest high level language. We should not underestimate this language. Furthermore, A good thing is this mostly big organizations ask the questions related to c++. After learning this language you will be able to develop management systems, Emended systems, heavy games etc. 

learn c++ dowaste


 Furthermore, c++ has two types of programming one is procedural oriented which is the programming with the help of functions and second is object oriented programming which we access by using classes and objects with functions. We can also use data structures in this language. Now you can imagine how big is this language. Also we cannot learn this complete language in our entire life because this is about 40 to 50 years old language and in 40 to 50 years the growth in this language is too high. Most of the programmers take start from c++ but now it's on up to you what do you want to select c++ or any other language. Here is the big thing which I am thinking right now which is some students who want to go in web developing so If you are reading this then this article will be not for you sorry!

Because in the beginning you should definitely go with html then css and then JavaScript etc. I am suggesting c++ to them who want to become software engineer or any kind of developer. If you want to go android development then you should learn java after learning c ++ but you can also learn java first because there is not too much difference in both the language first difference is of syntax and second is java is most efficient for android development and c++ for game development. Now we should talk about the most important part of the article which is topics to learn in c++.

1) Flow Diagrams

2) Variable and initialization

3) If-Else conditions

4) Loops

5) Arrays

6) Functions

7) Recursion

8) File handling

9) Pointers

There are lot of other topics to learn in c++ but these are the main topics to learn procedural oriented programming for c++. So After learning this you can also learn the object oriented part for c++. I will write the whole article on opp so stay connected with dowaste.