Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home » Programming » Java » Programs » Basic » Page 2

Java program to print odd numbers in the range 1 to n

Suryateja Pericherla Categories: Basic. No Comments on Java program to print odd numbers in the range 1 to n

In this article we will learn to implement a Java program to print odd numbers in the range 1 to n. A java program is provided below that reads n value from the user and prints the odd numbers in the range 1 to n.   Program is as follows: import java.util.Scanner; public class Driver […]

Read the rest of this entry »

Java program to print sum of first n natural numbers

Suryateja Pericherla Categories: Basic. No Comments on Java program to print sum of first n natural numbers

In this article we will learn to implement a Java program to print sum of first n natural numbers. A Java program is provided below which reads n and prints the sum of the first n natural numbers.   Following program reads a number n from the user and displays the sum of first n […]

Read the rest of this entry »

Java program to compute the sum of digits in a given integer

Suryateja Pericherla Categories: Basic. No Comments on Java program to compute the sum of digits in a given integer

In this article we will learn to implement a java program to compute the sum of digits in a given integer. A java program is provided below which reads a number from the user and prints out the sum of individual digits in the given number. For example, if the given number is 1234, program […]

Read the rest of this entry »

Java program to print Fibonacci series up to n terms

Suryateja Pericherla Categories: Basic. No Comments on Java program to print Fibonacci series up to n terms

In this article we will learn to implement a Java program to print Fibonacci series up to n terms. A java program is provided below which accepts the number of terms to display in the Fibonacci series and prints it:   Program is as follows: import java.util.Scanner; public class Driver { public static void main(String[] […]

Read the rest of this entry »

Java program to add two numbers

Suryateja Pericherla Categories: Basic. 2 Comments on Java program to add two numbers

In this article we will learn to implement a Java program to add two numbers. A java program is provided below which reads two numbers from the user and displays their sum.   Program is as follows: import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter […]

Read the rest of this entry »

Java program to generate random numbers

Suryateja Pericherla Categories: Basic. No Comments on Java program to generate random numbers

In this article we will learn to implement a Java program to generate random numbers. A Java program is provided below to generate a set of random numbers between two numbers x1 and x2, and x1>0.   Program is as follows: import java.util.*; class RandomGen { public static void main(String args[]) { int min = […]

Read the rest of this entry »

Java program to print prime numbers from 1 to n

Suryateja Pericherla Categories: Basic. No Comments on Java program to print prime numbers from 1 to n

In this article we will try to implement a Java program to print prime numbers from 1 to n. A Java program is provided below that prompts the user for an integer and then prints out all prime numbers up to that integer.   Program is as follows: import java.util.Scanner; class Prime { void primeGen(int […]

Read the rest of this entry »

Java program to print the nth element in the Fibonacci series

Suryateja Pericherla Categories: Basic. No Comments on Java program to print the nth element in the Fibonacci series

In this article we will learn to implement a Java program to print the nth element in the Fibonacci series. A Java program is provided below to print the nth element in the Fibonacci series using both non-recursive and recursive methods.   Program is as follows: import java.util.*; class Fibonnaci { int nFib(int n) { […]

Read the rest of this entry »
Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory