Basic Syntax & First Code Build

Basic Syntax & First Code Build


Here is the syntax list for beginners to know how to start coding.

  • Header Files
    • #include<bits/stdc++.h>
  • Function Syntax
    • cin>>
    • cout<<
    • endl
  • Data Type
    • int
    • string
    • char
    • double
    • float
  • Structure
    • #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      //**ALL MAGIC HERE** --> Commented using '//'
      }
The header file given above is usually enough for any code since it is a combined file of almost all C++ header files.

The cin must have >> and cout must have << and all code usually ends with a ";"

int accepts integer numbers between -2,147,483,648 to 2,147,483,647.
string accepts inputs like agh3487bkk.

You can guess and then check what the other data types do.

With this knowledge, try and see if you can generate this output, if you just got started in C++, then see the code and get the idea and then try it on your own.


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string username;
    cout<<"Enter your username - ";
    cin>>username;
    
    cout<<endl;
    
    cout<<"Welcome to ABC Online Banking "<<username<<endl;
    
    cout<<"What would you like to do?"<<endl;
    cout<<"1.Deposit"<<endl;
    cout<<"2.Withdraw"<<endl;
    cout<<"3.Loans"<<endl;
    cout<<"4.Credit Score"<<endl;
    
    int dothis;
    
    cout<<"Enter your option - ";
    cin>>dothis;
    
    cout<<"You selected option "<<dothis;
}

Hope this helps you get started with coding ;-)

Comments