Skip to main content

#logicalcoding Write a program to print 1 to 100 number in java | Logic...

Write a program to print 1 to 100 number in java.

If you want to become a part of step-by-step to become a logical programmer. Then this video and website for you. So join this website and my youtube channel and become a part of this event. I am going to discuss Java programming in java. become a java logical programmer in java. Software having knowledge about this logic and standard coding practice of these videos.




How to become a logical programmer series.

Question 3: Write a program to print 1 to 100 number in java. Take one value from the user and print the 1 to n number natural number in java.

Code:

    import java.util.Scanner;
class Numberp 
{
public static void main(String[] args) 
{
Scanner sc=new Scanner(System.in);
//System.out.println("Enter the Number:");don't used
int n=sc.nextInt();
//Validate -ve,+ve,0
if(n<1){
System.out.println("Please enter Valid Number");
System.exit(0);
}
for(int i=1;i<=n;i++){
         
         System.out.print(i+" ");
if(i<n)
System.out.print(",");
}
System.out.println(".");
    }
}




Output:

First-1: 

n=- -5
  Please enter the valid number

Second:

n=10

1,2,3,4,5,6,7,8,9,10.

Third:
n=5

1,2,3,4,5.

  



Comments

Popular posts from this blog

Difference between Traditional programming languages and object-oriented programming languages..?

 What are Traditional programming languages and object-oriented programming languages..? or Difference between Traditional programming language  and object-oriented programming language Here....what is Traditional programming language and object-oriented programming language..? or Difference between Traditional programming language to help you make the new concepts, you are learning            as a beginner to  become a Master in any programming it's really very most important: Traditional programming language 1.Traditional computer programming has been around for more than a      century, with the first known computer program dating back to the mid-1800s.  2.Traditional Programming refers to any manually created program     that uses input data and runs on a computer to produce the output. 3.But for decades now, an advanced type of programming has revolutionized     business, particularly in ...

Top 100 Logical Question in java | Written test exam question | Logical programming question paper in java to crack the written test exam.

                                  The written  test exam question     If you want to crack the written test exam like TCS , INFOSYS , and WIPRO than you want these questions. this question is very useful for you if you are in college. before any drive for MNC  company you are readily forgiven the exam of this company so, this is for you. This question is very useful for developing logical skills in the programming language. If you want to become a good logical and standard coder than definitely this video for you don't miss this question. As you know logic is the power of the world if you have logic you can solve and find the solution to any type of problem. So, just focus on the logic noting else.         List of Question :       1. Write a Java program to print 'Hello' on screen and then print your name on a separate line. ...

Top 50 HTML Interview Question (Most popular in the interview) | important html interview question

😀  Hello everyone. As you all know that to build a software project there are 3 Major categories to develop.😂 1.Front End  2.Middle Ware 3.Back End To crack the interview in front-end technology am going to give top FAQs which take place in your interview.so... Let's start now. TOPMOST FAQ's IN HTML   The first question raised by the interviewer is 1)What is HTML? HTML is a HyperText Markup Language. It is used for the creation and display of attractive, interactive, and dynamic web pages. By Tim Berners Lee's father of web environment. 2)What is the importance of Doctype in HTML? ​It is written at the top of the HTML document.​It is not a tag.​It tells the browser about the HTML version. 3)Define a TAG. ​A Tag or Element is said to be the text placed between Left angular brace " <" and right angular brace " >".   Syntax :   < .......... >    :     < html>   Do you know there are two types of ...