English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

How to print without using C loops1to10numbers between 0?

There are several ways to print numbers without using loops, such as using recursive functions, goto statements, and creatingmain()Functions.

This is an example of printing numbers in C language.

Example

#include<stdio.h>
int number(int val) {
   if(val<=100) {
      printf("%d\t",val);
      number(val+1);
   }
}
int main() {
   int val = 1;
   number(val);
   return 0;
}

Output Result

12345678910111213 14151617181920212223242526 27282930313233343536373839 40414243444546474849505152 53545556575859606162636465 66676869707172737475767778 79808182838485868788899091 9293949596979899100

In the above example, a function number is created using the parameter val. If val is less than or equal to100, then the value is printed and incremented1. Inmain()In the function, val is initialized as1is called function number.

if(val<=100) {
   printf("%d\t",val);
   number(val+1);
}