
Assignment  Looping

WAP to print numbers from 1 to 100.

WAP to print the factors of a Number.

WAP to print the Even Factors of the Number.

WAP to print the Odd factors of a Number.

WAP to print the sum of even factors of a Number.

WAP to input a number and check whether it is perfect number or not.
A perfect number is a number which is equal to sum of its factors excluding itself.
example:
6 is prefect number.
6=1+2+3 
WAP to input a number and check whether it is prime number or not. Prime numbers are the number which has only two factors one and itself.
example:
7 is prime number .Factors of 7 are 1 and 7. 
WAP to find the HCF and LCM of two numbers.
The Highest Common Factor (H.C.F) of two (or more) numbers is the largest number that divides evenly into both numbers. In other words the H.C.F is the largest of all the common factors.

WAP to count the number of digits of number.
Input 456
Ouput:3 
WAP to input a number and check whether it is palindrome number or not. Palindrome Number: Number=reverse of a number
Input 456
Ouput:3 
WAP to input a number and find the sum of first and last digit of number.
Input 456
Ouput:4+6=10 
WAP to input a number and check whether it is Armstrong Number or Not
Armsrong Number: Sum of cube of each digit of a number =Original number 
WAP to input a number and check whether it is Special Number or Not
Special Number: Sum of factorial of each digit of a number =Original number


Write a program to print series ...

1,2 3, 4 ..................................up to 10

1 , 2 , 5 , 7 ,...............................................upto 20 terms

1, 2, 4, 8, 16 .............................up to 30 terms.

1, 5, 25, 125,............................ upto 20 terms.

100 , 97, 94, 91.......................................upto 10

1+2+3+4.....................................upto 20 terms.

1+7+13+19...........................upto 25 terms.


Assignment Pattern

Pattern 1)

Pattern 2)

Pattern 3)

Pattern 4)

Pattern 5)

Pattern 6)


Assignment  Arrays

WAP to input 10 numbers in an array and print the sum of all the numbers

WAP to input 10 numbers in an array and print the sum of all odd numbers.

WAP to input 10 numbers in an array and print the sum of all even numbers.

WAP to input 10 numbers in an array and print the sum of all the numbers at even position .

WAP to input 10 numbers in an array and print the sum of all the numbers at oddposition .

WAP to input 10 numbers in an array and print the sum of all the odd numbers at odd position .

WAP to input 'n' numbers in an array and print the count of all odd numbers.

WAP to input 'n' numbers in an array and print the count of all even numbers.

WAP to input 'n' numbers in an array and find the average.

WAP to input 'n' numbers in an array and find the average of all odd numbers in an array. .

WAP to input 'n' numbers in an array and find the largest number along with its position..

WAP to input 'n' numbers in an array and find the smallest number along with its position..

WAP to input 'n' numbers in an array and sort the elements using any sorting technique..

WAP to input 'n' numbers in an array and remove the duplicate elements and then print the elements of array.
/*This program shows how we take input from user and put the elements in 1D array. and then print using for loop and foreach loop */ import java.util.Scanner; class Example { public static void main(String[] args) { //printing the message on console System.out.println("Enter the size of array"); //we have to use java.util.Scanner for taking the size from the keyboard. //We can also use other ways to take input from a user. Scanner ob = new Scanner(System.in); int size = ob.nextInt(); //declearing array of size 'size' int a[] = new int[size]; //taking input from user and filling to array using forloop for (int i = 0; i < size; i++) { a[i] = ob.nextInt(); } //now perform stuff on array //now printing the elements of array using normal for loop System.out.println("printing array using forloop"); for (int i = 0; i < size; i++) { System.out.print(a[i] + "\t"); } System.out.println(); System.out.println("printing array using foreach loop"); //printing the elements of array using foreach loop for (int i : a) { System.out.print(i + " "); } } }
Output:Enter the size of array 5 12 65 34 87 34 printing array using forloop 12 65 34 87 34 printing array using foreach loop 12 65 34 87 34
