Javatpoint Logo
Javatpoint Logo

Simple Programs

Let's see the simple example of printing 1 to 10 numbers using respective languages.

Program in C

In this program, the value of i is 1. The "do-while" loop is used in this program to print the numbers from 1 to 10 using printf() function.

Program in C++

In this program, i contains the value 1. The do while loop is used to print the numbers from 1 to 10 using cout object.

Program in C#

In this example, i contains the value 1. The do-while loop is used in this program to print the numbers from 1 to 10 using Console.Write().

Program in Java

In this example, i contains the value 1. The do-while loop is used in this program to print the numbers from 1 to 10 using System.out.print().

Program in JavaScript

In this program, variable i contains the value 1. The do while loop is used in this program to print 1 to 10 numbers using document.write() funtion.

Program in Perl

In this program, $i contains the value 1 and printf() function is used to print the numbers from 1 to 10.

Program in PHP

In this program, $i contains the value 1 and an echo statement is used to print the values of i.

Program in Ruby

In this program, ruby contains "do if" block. This loop opposes the "if-condition" i.e the i>10. Therefore, the loop is executed till i=10. When, i becomes 11, control terminates the loop.

Program in Swift

In this program, variable i contains the value 1.The "repeat -while" loop is executed till i=10. When i becomes 11, it leads to the termination of a loop.

Output:

1 2 3 4 5 6 7 8 9 10

C language


HI , You are in C language Factorial Program.

C++ language


HI , You are in C++ language Factorial Program.

JAVA language


HI , You are in JAVA language Factorial Program.

Python language


HI , You are in Python language Factorial Program.

Angular language


HI , You are in Angular language Factorial Program.

Ruby language


HI , You are in Ruby language Factorial Program.

iOS language


HI , You are in iOS language Factorial Program.

Javascript language


HI , You are in Javascript language Factorial Program.

C# language


HI , You are in C# language Factorial Program.

Perl language


HI , You are in Perl language Factorial Program.

C language


HI , You are in C language Factorial Program.

C++ language


HI , You are in C++ language Factorial Program.

JAVA language


HI , You are in JAVA language Factorial Program.

Python language


HI , You are in Python language Factorial Program.

Angular language


HI , You are in Angular language Factorial Program.

Ruby language


HI , You are in Ruby language Factorial Program.

iOS language


HI , You are in iOS language Factorial Program.

Javascript language


HI , You are in Javascript language Factorial Program.

C# language


HI , You are in C# language Factorial Program.

Perl language


HI , You are in Perl language Factorial Program.



Help Others, Please Share

facebook twitter pinterest