Control Statements and Basic Java Programs For Practice

Chakresh Tiwari
2 min readApr 16, 2021

--

Photo by www.zanda. photography on Unsplash

In this article, we are going to cover some basic programs related to control statement learning.

Introduction:

Control statements are those which help programmers to execute program conditionally. Like If some condition is true then do something else do other things.

Control Statements are:

  1. If else
  2. if else if else
  3. switch

Loops:

Whenever we want to do some task repetitively we use loops there Like if we print numbers from 1 to 10. then either we can write 10 print statements or we can use for that.

Types of Loops:

  1. for loop: If we know in advance how many times we need to process data then we use for loop.
  2. Advance for loop: we can iterate using that also it is more easy syntax and new.
  3. while loop: If we don't know the number of times then while loop.
  4. do-while loop: It will execute the statement once even before checking the condition.
  5. forEach loop: This is advanced loop came in java 8.

15 Basic Programs to Practice:

1.Check whether a year is Leap Year or not.
2.Check whether a user is a Valid Voter or not.
3. Check whether a number is a Positive Number
4. Check whether a Number is Greater than 10
5. Find greatest among three numbers
6.Write a Java program that keeps a number from the user and generates an integer between 1 and 7 and displays the name of the weekday.
7.Write a Java program to find the number of days in a month
8.Write a program in Java to display the first 10 natural numbers
9.Write a program in Java to input 5 numbers from the keyboard and find their sum and average.
10. Write a program in Java to display the cube of the number upto a given an integer.
11.Write a program in Java to display the multiplication table of a given integer.
12.Check whether a given number is even or odd.
13.Check whether a given number is Palindrome Number
14.Check whether a given number is Armstrong Number
15. Find a Factorial of a number.

For the Solution to these programs, you can refer to my github. In the next article, I will give a solution also.

If you want to learn more join me on Linkedin. We are running live classes with a job guarantee.

Thanks for reading!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Chakresh Tiwari
Chakresh Tiwari

Written by Chakresh Tiwari

Software Engineer at Cisco(Appdynamics) , Sharing my knowledge and experience related to work. I am here to help learners to prepare for tech interviews.

No responses yet

Write a response