17. with return without parameter , write a program using a function to print table of "n" variable.
Answers
Answered by
2
The given program is written in Java.
import java.util.*;
public class Table{
public static void main(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
System.out.println("Multiplication table of "+n+" is given below - \n");
for(int i=1;i<=10;i++)
System.out.println(n+" * "+i+" = "+n*i);
}
}
- Accept the number from the user, say n.
- Repeat from i = 1 to 10.
- Display the value of n * i.
See the attachment for output.
Attachments:
Similar questions