Program to print the table of given number using function in java.
import java.util.*;
public class function{
public static void printTable(int n){
int tab;
for(int i=1; i<=10; i++){
tab=n*i;
System.out.println(tab);
}
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.print("enter a number=");
int n=sc.nextInt();
System.out.println("the table of given number is=");
printTable(n);
}
}
■》Output->
enter a number= 5
the table of given number is=>
5
10
15
20
25
30
35
40
45
50
Comments
Post a Comment