Write a program to print 1 to 100 without using any numerical value Last Updated : 11 Mar, 2024 Comments Improve Suggest changes Like Article Like Report Write a program to print numbers from 1 to 100 without using any numerical value. Output Format: 1 2 3 4 5 6 7 8 9 10 11 ....... 97 98 99 100 Approach: Use ASCII characters to make count of numbers i.e. 'A' character has ASCII value equal to 65 and 'B' has ASCII value 66, so we can subtract 'A' from 'B' to get the starting value 1. Now, we can run a loop till we do not reach 'd' as d has ASCII value equal to 100. Step-by-step algorithm: Initialize an integer i with 'B' - 'A'.Run a loop till i <= 'd'.In each iteration, print i and increment i using i++.After all the iterations, we will have all numbers from 1 to 100. Below is the implementation of the approach: C++ #include <iostream> using namespace std; void printSequence() { // loop starting with null character for (int i = 'B' - 'A'; i <= 'd'; i++) { // printing values cout << i << " "; } } int main() { printSequence(); return 0; } Java /*package whatever //do not write package name here */ import java.io.*; class GFG { public static void main(String[] args) { printSequence(); } public static void printSequence() { // loop starting with null character for (int i = 'B' - 'A'; i <= 'd'; i++) { // printing values System.out.print(i + " "); } } } C# using System; class MainClass { static void PrintSequence() { // Loop starting with null character for (int i = 'B' - 'A'; i <= 'd'; i++) { // Printing values Console.Write(i + " "); } } public static void Main(string[] args) { PrintSequence(); } } Javascript function printSequence() { // Array to store the values let sequence = []; // Loop starting from the difference of ASCII values of 'B' and 'A' for (let i = 'B'.charCodeAt(0) - 'A'.charCodeAt(0); i <= 'd'.charCodeAt(0); i++) { // Pushing values to the array sequence.push(i); } // Joining the values with a space and printing the result console.log(sequence.join(" ")); } printSequence(); Python3 def print_sequence(): # loop starting with null character for i in range(ord('B') - ord('A'), ord('d') + 1): # printing values print(i, end=" ") print_sequence() Output1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70...Time Complexity: O(1)Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Write a program to print 1 to 100 without using any numerical value S sam_2200 Follow Improve Article Tags : Computer Science Fundamentals Similar Reads How to print a number 100 times without using loop and recursion in C? It is possible to solve this problem using loop or a recursion method but what if both are not allowed? A simple solution is to write the number 100 times in cout statement. A better solution is to use #define directive (Macro expansion) CPP // CPP program to print "1" 100 times. // Prints 1 min read Print 1 to 100 without loop using Goto and Recursive-main Our task is to print all numbers from 1 to 100 without using a loop. There are many ways to print numbers from 1 to 100 without using a loop. Two of them are the goto statement and the recursive main. Print numbers from 1 to 100 Using Goto statement Follow the steps mentioned below to implement the 5 min read How will you print numbers from 1 to 100 without using a loop? If we take a look at this problem carefully, we can see that the idea of "loop" is to track some counter value, e.g., "i = 0" till "i <= 100". So, if we aren't allowed to use loops, how can we track something in the C language?Well, one possibility is the use of 'recursion', provided we use the t 12 min read Getting Started with Number Programs in Programming Numbers play a crucial role in programming, whether it's dealing with simple digits or diving into more complex concepts like number systems, arithmetic, series, sequences, random numbers, and special numerical values. This article is your guide to understanding how to code numbers in programming, u 2 min read Print a number 100 times without using loop, recursion and macro expansion in C? It is possible to solve this problem using loop or a recursion method. And we have already seen the solution using #define directive (Macro expansion) but what if all three are not allowed? A simple solution is to write the number 100 times in cout statement. A better solution is to use concept of C 1 min read Like