

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to print numbers from 1 to 100 without using loop
Here we will see how to write a C program that can print numbers from 1 to 100 without using any kind of loops.
This problem can be solved using the recursion. We will create a function that will be called recursively. As we know that a recursive function has basically two sections. The base case and the recursive call and other operation. In this function the base case is the argument n is greater than 1. Until it reaches 1, the function will be called recursively. Now at the end it will print the value of n. Thus the entire system will generate the numbers.
Example Code
#include<stdio.h> void generate_numbers(int n) { if(n > 1) { generate_numbers(n - 1); //call the function with the argument n-1 } printf("%d ", n); } main() { generate_numbers(100); }
Output
1 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
- Related Questions & Answers
- How will you print numbers from 1 to 100 without using loop in C?
- Print 1 to 100 in C++, without loop and recursion
- C Program to print numbers from 1 to N without using semicolon
- Python program to print all Disarium numbers between 1 to 100
- Python program to print all Happy numbers between 1 and 100
- Java program to print prime numbers below 100
- C program to print four powers of numbers 1 to 9 using nested for loop
- Java Program to print Number series without using any loop
- C program to print number series without using any loop
- Print a number 100 times without using loop, recursion and macro expansion in C
- Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
- Golang Program to Print the Numbers in a Range (1, upper) without Using any Loops
- Write a program to append Magic Numbers from 1 to 100 in a Pandas series
- Python Program for Print Number series without using any loop
- Print Number series without using any loop in Python Program
Advertisements