Computer Science, asked by preksham, 8 hours ago

17. with return without parameter , write a program using a function to print table of "n" variable.

Answers

Answered by anindyaadhikari13
2

\texttt{\textsf{\large{\underline{Solution}:}}}

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);

   }

}

\texttt{\textsf{\large{\underline{Logic}:}}}

  • 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