0% found this document useful (0 votes)
18 views1 page

Java Exercise 1

Uploaded by

digitalm4044
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)
18 views1 page

Java Exercise 1

Uploaded by

digitalm4044
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
You are on page 1/ 1

‭Java - Introduction to Programming‬

‭Exercise 1‬

‭Questions‬

1‭ .‬ E ‭ nter 3 numbers from the user & make a function to print their average.‬
‭2.‬ ‭Write a function to print the sum of all odd numbers from 1 to n.‬
‭3.‬ ‭Write a function which takes in 2 numbers and returns the greater of those‬
‭two.‬
‭4.‬ ‭Write a function that takes in the radius as input and returns the‬
‭circumference of a circle.‬
‭5.‬ ‭Write a function that takes in age as input and returns if that person is eligible‬
‭to vote or not. A person of age > 18 is eligible to vote.‬
‭6.‬ ‭Write an infinite loop using do while condition.‬
‭7.‬ ‭Write a program to enter the numbers till the user wants and at the end it should‬
‭display the count of positive, negative and zeros entered.‬
‭8.‬ ‭Two numbers are entered by the user, x and n. Write a function to find the value of‬
‭𝑛‬
‭one number raised to the power of another i.e.‬‭𝑥‬ ‭.‬
‭9.‬ ‭Write a function that calculates the Greatest Common Divisor of 2 numbers.‬
‭(‬‭BONUS‬‭)‬
‭10.‬‭Write a program to print Fibonacci series of n terms where n is input by user :‬
‭0 1 1 2 3 5 8 13 21 .....‬
‭In the Fibonacci series, a number is the sum of the previous 2 numbers that‬
‭came before it.‬
‭(‬‭BONUS‬‭)‬

‭Apna College‬

You might also like