Fibonacci number (0 1 1 2 3 5 8 13 21 34)

 Question: 0   1   1   2   3   5   8   13   21   34

*Used while loop
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter number of terms: ");
int t=scan.nextInt();
//0   1   1   2   3   5   8   13   21   34
int i=0, j=1, k=2;
while (k <= t) {
    System.out.print(" "+i + " "+j);
    i=i+j;
    j=i+j;
    k+=2;
}
}
}
====================
*Used For Loop
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter number of terms: ");
int t=scan.nextInt();
//0   1   1   2   3   5   8   13   21   34
int i=0, j=1, sum;
for (int m=1;m<=t; ++m) {
    System.out.print(i + " ");
    sum=i+j;
    i=j;
    j=sum;
}
}
}




Read & Write using string (Name and Father name)

 import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
String s1, s2;

Scanner scan = new Scanner(System.in);
System.out.print("Please enter your name: ");
s1 = scan.nextLine();

System.out.print("Please enter your father name: ");
s2 = scan.nextLine();

System.out.println(s1+" "+s2);
}
}
=================


Even or Odd

 public class Main
{
public static void main(String[] args) {
int num = 19;
if(num%2==0)
    System.out.println("The number is even.");
else
    System.out.println("The number is odd.");
}
}
Output: The number is odd.
====================
*import from user

import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter any integer number: ");
int num = scan.nextInt();
if(num%2==0)
    System.out.println("The number is even.");
else
    System.out.println("The number is odd.");
}
}

Max Program (Find the Max number)

public class Main
{
public static void main(String[] args) {
int x = 0;
int y = 1;
int max = x>y?x:y;

System.out.println("x = "+ x);
System.out.println("y = "+ y);
System.out.println("max = "+ max);
}
}
Output:
x = 0
y = 1
max = 1
======================
public class Main
{
public static void main(String[] args) {
int x = 4;
int y = 1;
int max;
if (x > y)
    max = x;
else
    max = y;
System.out.println("x = "+ x);
System.out.println("y = "+ y);
System.out.println("max = "+ max);
}
}
Output:
x = 4
y = 1
max = 4
===============
#input from user







JAVA PROGRAMMING

 public class Main

{

public static void main(String[] args) {

System.out.println("Hello World");

}

}

Pyramid pattern programs in C

https://www.programiz.com/c-programming/examples/pyramid-pattern

R1:Array&String