from where i need to take input and where i need to print output
@kalpesh2704 : You need to read input from standard input and print your answer on standard output . No file handling etc .
@kalpesh2704 : you can use scanf() as taking input for C/C++ program and for output you can use printf(). for Java you can use BufferedReader with System.in as input stream and System.out.println() for output.
C: use scanf();
c++: use cin<<
java use Buffered reader
printing output depends on patter how u want a output check any sample solution to see how to print output in specified manner.
cin takes more time…u can use scanf() as well in C++.