Deepika java
Deepika java
Deepika java
PRACTICAL FILE
Submitted By : Submitted To :
}
2. WAP to Print Sum of Numbers up 1 to n
import java.util.Scanner;
int n = sc.nextInt();
int sum = 0;
sum += i;
}
3. WAP to Print Palindrome of a Number
import java.util.Scanner;
while (num != 0) {
num /= 10;
if (original == reverse) {
} else {
}
4. WAP to Print Armstrong Number
import java.util.Scanner;
while (num != 0) {
num /= 10;
}
if (original == sum) {
} else {
}
5. WAP to Print Factorial of a Given Number
import java.util.Scanner;
int n = sc.nextInt();
long factorial = 1;
factorial *= i;
}
6. WAP to Check if a Number is Prime or Not
import java.util.Scanner;
int n = sc.nextInt();
if (n <= 1) {
isPrime = false;
} else {
if (n % i == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
} else {
System.out.println(n + " is not a prime number.");
}
7. WAP to Print Reverse of a Number
import java.util.Scanner;
int reverse = 0;
while (num != 0) {
num /= 10;
}
System.out.println("Reversed number is: " + reverse);
}
8. WAP to Print Even Numbers up 1 to n
import java.util.Scanner;
int n = sc.nextInt();
}
9. WAP to Print Fibonacci Series
import java.util.Scanner;
int n = sc.nextInt();
int a = 0, b = 1, next;
System.out.println("Fibonacci series:");
next = a + b;
a = b;
b = next;
}
10. WAP to Print Average of First 10 Natural Numbers
int sum = 0;
sum += i;
}
11. WAP to Print Maximum Element in an Array
import java.util.Scanner;
int n = sc.nextInt();
arr[i] = sc.nextInt();
max = arr[i];
}
12. WAP to Print Second Largest Element in an Array
import java.util.Scanner;
int n = sc.nextInt();
arr[i] = sc.nextInt();
secondLargest = largest;
largest = arr[i];
secondLargest = arr[i];
}
}
if (secondLargest == Integer.MIN_VALUE) {
} else {
}
13. WAP to Check Whether a Number is Even or Odd
import java.util.Scanner;
if (num % 2 == 0) {
} else {
}
14. WAP to Concatenate Two Strings
import java.util.Scanner;
}
15. WAP to Print Multiplication Table in an Array
import java.util.Scanner;
int n = sc.nextInt();