0% found this document useful (0 votes)
2 views2 pages

Assignment 1 Core Java

The document outlines a programming assignment consisting of ten tasks. These tasks include calculating factorials, generating Fibonacci series, sorting arrays, checking leap years, printing prime numbers, calculating triangle area, summing natural numbers, reversing arrays, printing even numbers, and displaying a triangle pattern using a two-dimensional array. Each task requires the implementation of specific algorithms and user input where applicable.

Uploaded by

Amanpreet
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Assignment 1 Core Java

The document outlines a programming assignment consisting of ten tasks. These tasks include calculating factorials, generating Fibonacci series, sorting arrays, checking leap years, printing prime numbers, calculating triangle area, summing natural numbers, reversing arrays, printing even numbers, and displaying a triangle pattern using a two-dimensional array. Each task requires the implementation of specific algorithms and user input where applicable.

Uploaded by

Amanpreet
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment 1

1. Write a program to calculate the factorial of a number using a while loop.

The factorial of a positive number n is given by:

factorial of n (n!) = 1 * 2 * 3 * 4 * ... * n

2. Write a program to print fibonacci series (10 values).

A series where the next term is the sum of previous two terms. The first

two terms of the Fibonacci sequence is 0 followed by 1.

The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...

3. Write a program to sort the elements of an array in ascending order.

4. Write a program to check whether the current year is leap year or not. Users will

enter a year value.

5. Write a program to print the first 10 prime numbers.

6. Write a program to calculate the area of a triangle. Users will enter the values for

base and height of the triangle.

7. Write a program to print the sum of the first 20 natural numbers.


8. Write a program to reverse the elements of an array where the array size as well as the

array values are entered by the user.

9. Write a program to print only even numbers till 50.

10. Write a program to print this output using a two-dimensional array.

Triangle Array

00

000

0000

00000

000000

0000000

00000000

000000000

0000000000

You might also like