Note: Class name and variable names are used in such a way for a better understanding. It can be changed according to the user's choice. Please refer to code snippets for a better understanding of indentation and comments. Please save the file name as the class name which contains the main function
Program code: sqr_num.java
import java.io.*;
import java.util.Scanner;
public class sqr_num
{
public static void main(String[] args)
{
// scanner class
Scanner inp_read = new
Scanner(System.in);
// variable to store input
number
// and counter variable
int inp_num, ctr;
// asking input integer i.e highest
integer
System.out.print("Input integer i.e
the highest integer : ");
// reading the upper limit from the
user
inp_num = inp_read.nextInt();
// printing the squares using for
loop
for(ctr=1; ctr<=inp_num;
ctr++)
{
System.out.print(ctr + ":" + ctr*ctr + "\n");
}
}
}
Code Snippet

Sample output runs


write a code that will print all numbers and their squares between 1 and a given...
1.Given a positive integer number says n, write a java program to print the first n squared numbers recursively. Sample run 1: Enter the value of n: 5 ------------------------------------- First 5 square numbers are: 1 4 9 16 25 Sample run 2: Enter the value of n: 10 ------------------------------------- First 10 square numbers are: 1 4 9 16 25 36 49 64 81 100 Sample run 3: Enter the value of n: 12 ------------------------------------- First 12 square numbers are: 1...
Python programming: Write a while loop that prints a. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. b. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90 c. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16...
Write a small program that will calculate squares of numbers 1 to 5 and print the output as show below. [7 Marks] number 1, number squared 1 number 2, number squared 4 number 3, number squared 9 number 4, number squared 16 number 5, number squared 25 You want to determine the wavelength of two waves and the maximum possible wave height from the combination of the two waves. Produce an input/output diagram based on the above requirements.
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
Write a java program to print all the prime numbers below a certain given number. A prime number is defined as a number that can only be divided by 1 and itself. Requirements: 1. Accept the upper limit from the user as an integer. 2. You can assume the user input will be positive and smaller than INT MAX 3. Go from 1 to the number. If you happen to find a number that is prime, print it. The input...
Write a JAVA code snippet which prints out numbers between 0 and 1,000,000, BUT only print the numbers which are a multiple of 3.
ere is a short Processing program that intends to print out the square numbers (Links to an external site.)Links to an external site.: 1, 4, 9, 16, 25, 36, 49, and so on. void setup() { int[] squares; for(int i = 0; i < squares.length; i++) { squares[i] = i * i; } for(int s : squares) { println(s); } } Java will not allow this program to compile and run because of built-in memory protections. Which problem mentioned in...
Write a program to print all the prime numbers below a certain given number. A prime number is defined as a number that can only be divided by 1 and itself. Requirements: 1. Accept the upper limit from the user as an integer. 2. You can assume the user input will be positive and smaller than INT MAX 3. Go from 1 to the number. If you happen to find a number that is prime, print it. The input and...
Hi, I'm trying to write C code that will print the odd abundant numbers between 1 and 5000 and I've written a program for it but it doesn't work. If you would be able to help me fix it or point out where I went wrong that would be awesome. # include <stdio.h> int main () { int getSum(int n) int i, n, j, sum = 0; /* print initial statement to give context of program*/ printf("...
Write a program in C that stores the result of all
multiplications between 1 and 9 in a two-dimensional int array and
then prints the contents of the array to the screen. Also, write
some comments in the code.
Example:
Expected output: 1 4 6 7 8 8 1 12 14 16 18 4 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 1e 15 20 25 30 35 40...