C programming
C programming

Input a number less than 5 and print “Hello World” five times if the condition is true – Program by using for loop, do while loop and while loop

Input a number less than 5 and print “Hello World” five times if the condition is true – Program by using for loop, do while loop and while loop

C programming
C programming

Input a number less than 5 and print “Hello World” five times if the condition is true – Program by using for loop, do while loop and while loop

 

package com.company;

import java.util.Scanner;

public class etcprog
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int n;
        System.out.println("Input a number :");
        n = sc.nextInt();
        if (n<=5)
        {
            int i = 1;
            while(i<=5)
            {
                System.out.println("hello world");
                i++;
            }

            System.out.println("\n");

            for(int j=1 ; j<=5 ; j++)
            {
                System.out.println("hello world");
            }
            System.out.println("\n");

            int k=1;
            do{
                System.out.println("hello world");
                k++;
            }
            while(k<=5);
            System.out.println("\n");

        }
        else
            System.out.println("Invalid Input");


    }
}

 

 

Programmed by : Sadhana

 


 

Topics Covered :

  • loops in c
  • loops
  • for loop example in c
  • for loop examples
  • loops programming in c
  • loop
  • python
  • loops programming exercises
  • python loops
  • learn python
  • for loop solved problem
  • for loop
  • computer science
  • coding
  • software engineering
  • python tutorial
  • python programming
  • c for gate
  • c language
  • c programming lectures
  • c programming
  • hacking
  • c language tutorial
  • c language for beginners

 


 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

๐Ÿง‘โ€๐Ÿ’ป๐Ÿง‘โ€๐Ÿ’ปย Social Mediaย Linksย ofย Tech DCodeย :

๐Ÿ‘‰๐Ÿปย YouTube :ย https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
๐Ÿ‘‰๐Ÿปย Instagram :ย https://www.instagram.com/thetechdcode/
๐Ÿ‘‰๐Ÿปย Facebook Page :ย https://www.facebook.com/thetechdcode
๐Ÿ‘‰๐Ÿปย Twitter :ย https://twitter.com/thetechdcode
๐Ÿ‘‰๐Ÿปย Telegram Channel :ย https://t.me/thetechdcode
๐Ÿ‘‰๐Ÿปย Tech DCode Linktree :ย https://linktr.ee/thetechdcode
๐Ÿ‘‰๐Ÿปย My Personal Handles :ย https://linktr.ee/virtualshivamin

๐Ÿง‘โ€๐Ÿ’ป๐Ÿง‘โ€๐Ÿ’ปย Social Media Linksย ofย SHIVAM SINGHย (OWNER) :

๐Ÿ‘‰๐Ÿปย Instagram :ย https://www.instagram.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Facebook Page :ย https://www.facebook.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Twitter :ย https://twitter.com/virtualshivamin/
๐Ÿ‘‰๐Ÿปย Personal Linktree :ย https://linktr.ee/virtualshivaminย 

 

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *