Robotic moves  Hackerearth practice problem solution
Problem:
A robot’s initial position is
$(0,0)$and it can only move along Xaxis. It has
$N$moves to make and in each move, it will select one of the following options:
 Go to
 Go to
 Remain at its current position
Your task is to calculate
$\sum (abs(X)+abs(Y))$for all reachable
$(X,Y)$.
Note: Here,
$abs$denotes the absolute value.
See the sample explanation for better understanding.
Input format
 The first line contains
 The first line of each test case containing an integer
Output format
lines. For each test case, print a single integer as described in the problem statement.
Constraints
$1\le T\le 20000$
$1\le N\le 1e9$
He is initially at (0,0). He has 1 move to make, the positions where he can end up are (1,0),(1,0) and (0,0).
$\sum (abs(x)+abs(y))$
=abs(1)+abs(0)+abs(1)+abs(0)+abs(0)+abs(0)
=1+0+1+0+0+0
=2
Code:
Here I am going to give you two solution first one is on the basis of C language and second one is on the basis of c++ language which you can submit in c++14 and c++17 also
Solution 1 ( C language):
Solution 2 ( C++ language):
Recommended Post:

Hackerearth Problems:
 Very Cool numbers  Hacker earth solution
 Birthday party  Hacker earth solution
 Most frequent  hacker earth problem solution
 program to find symetric difference of two sets
 cost of balloons  Hacker earth problem solution
 Chacha o chacha  hacker earth problem solution
 jadu and dna  hacker earth solution
 Bricks game  hacker earth problem
 AntiPalindrome strings  hacker earth solution
 connected components in the graph  hacker earth data structure
 odd one out  hacker earth problem solution
 Minimum addition  Hackerearth Practice problem
 The magical mountain  Hackerearth Practice problem
 The first overtake  Hackerearth Practice problem
Data structure:
 Program to find cycle in the graph
 Implementation of singly link list
 Implementation of queue by using link list
 Algorithm of quick sort
 stack by using link list
 program to find preorder post order and inorder of the binary search tree
 Minimum weight of spanning tree
 Preorder, inorder and post order traversal of the tree
Key points: