Skip to main content

Lets get the basics right first!

So the first post was meant to explain the class and objects. Lets get into the syntactical knowledge of C++(You will love it!).

Input/Output -

In any language when you develop a software, it requires you to take the input and throw some output. In C++ it is pretty easy to do that.

I will explain it through a code snippet:

Input :

#include <iostream>

using namespace std;
int main(){
     int a;
     cin >> a;      // There is a variable "a". To take the input from the user we use "cin" along with      return 0;         the  >> that is overloaded to take the streaming input.
}

Output :

#include <iostream>

using namespace std;
int main(){
     int a;
     cin >> a;     
     cout << a; // We took the input in the previous line and now we are giving the output through                                cout along with "<<" operator overloaded for giving out output. 
     return 0;           
}


Comments

Popular posts from this blog

Lets get Started!

What is C++?  C++ is an object-oriented language. Now lets first know what an object-oriented language is!I will follow the top-down approach. When we say object oriented it means that we deal with objects here. But what is an object ? An object is an instance of a class. What is a class?  A class is a user-defined data structure that actually has some data members and some functions. Now, what are data members and functions? Data members are the ingredients of a class that contains some data.  Functions(known as methods in Java) are a set of operations that are performed according to our need. For example,  Consider the following code snippet: int add(int a, int b){       return a + b; } The following code snippet is a function named "add" that has a return type of integer type and takes in 2 parameters of integer type a and b. It returns the sum of a and b.  Lets see how a class looks: class Solution{       int x, y ;       publ