Professional Documents
Culture Documents
Experiment No. 1
1. Aim:
Hackerrank problem related to loops.
2. Problem statement:
Given an integer, N, print its first 10 multiples. Each multiple N*I (Where 1<=i<=10) should be printed on a
new line in the form: N* I = Results.
3. Introduction:
To print the first 10 multiples of a number we need to execute the program using loops, as loops allow us to
execute the number of iterations in a go. In this program, as we know the number of iterations to be executed so
I have used for loop to create the table. Also, I have taken the number from the user, of which we need to print
the multiples.
4. Software Used:
Hackerrank
5. Hardware requirements:
6. Algorithm:
1) Start.
2) Take N as input. Initialize i=1.
3) Print N*i.
4) Repeat 3 using for loop a total of 10 times and increment i with 1 each time.
5) Stop.
7. Code:
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.Scanner;
for(int i=1;i<11;i++){
System.out.println(n+" x "+i+" = "+n*i);
}
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING