mardi 2 mars 2021

Write a program that prints the multiplication table from 1 to 5. 1 X 1 = 1 1 X 2 = 2 ............ 5 X 9 =45 5 X 10 = 50 in Java [closed]

package cse215;

import java.util.Scanner;

public class C {

   public static void main(String[] args) {

       int num,i;
       
       Scanner sc=new Scanner(System.in);
               System.out.println("Enter the number:");
       num=sc.nextInt();
       for(i=1;i<=10;i++) {
           System.out.println(num+"*"+i+ "=" +(num*i)); 
       }
   
   }
       
}

What should I do if I don't want to take user input?

Aucun commentaire:

Enregistrer un commentaire