Lab Report File: Introduction To JAVA Programing
Lab Report File: Introduction To JAVA Programing
[BCSL 506]
1
1. Program to print sum of two numbers.
/**
*/
import java.util.Scanner;
num1 = inp.nextInt();
num2 = inp.nextInt();
sum = num1+num2;
2
OUTPUT-
3
2.Program to print Fibonacci series with and without
recursion.
import java.util.Scanner;
if(count>2){
temp3=temp1+temp2;
temp1=temp2;
temp2=temp3;
System.out.print(" "+temp3);
Rec_series(count-1);
}
}
{ int count;
Scanner inp = new Scanner(System.in);
System.out.println("\f Program to print fibonacci series");
for(int i=2;i<count;++i)
{ temp3=temp1+temp2;
System.out.print(" "+temp3);
temp1=temp2;
temp2=temp3;
}
Rec_series(count); }}
4
OUTPUT-
5
3.Program to check prime numbers
/**
*/
import java.util.Scanner;
{ int temp;
boolean flag=true;
int num=inp.nextInt();
for(int i=2;i<=num/2;i++)
{ temp=num%i;
if(temp==0)
{ flag=false;
break;
}
if(flag==true)
else{
6
OUTPUT-
7
4.Program to check palindrome number.
/**
Program to check palindrome
*/
import java.util.Scanner;
{
public static void main(String args[])
{
int temp, num1, num2=0, a;
Scanner inp = new Scanner(System.in);
System.out.println("\f Program to check Palindrome");
System.out.println("Enter the number :");
num1= inp.nextInt();
temp= num1;
while(temp>0){
a=temp%10;
num2=(num2*10)+a;
temp=temp/10;
}
if(num2==num1)
{ System.out.println("Given number is a palindrome number ");
}
else{
System.out.println("Given number is not a palindrome number "); }
}
}
8
OUTPUT-
9
10