Print numbers 1 to 100

Print Numbers without using loop

Print numbers 1 to 100 without using loop in c

There are several methods to print numbers without using loops like using a recursive function, goto statement, and creating a function outside the main() function.     

Printing numbers from 1 to 100 using two methods:

1. Using goto statement:

#include <stdio.h> 
#include<conio.h>  
void main() 
{ 
      int i = 0;
      clrscr();
begin: 
 	   i = i + 1; 
printf("\n\t\t\t...Welcome To EduNews.Tech... ");
       printf("%d ", i);

    if (i < 100)
      goto begin;
printf("\n\n\n\t\t\tThankyou for Joining Us !");
    printf("\n\t\t\t!Regards EduNews !");
    //return 0; 
getch();
}

Program Output:

print numbers

2 Using recursive main function:

#include <stdio.h> 
#include<conio.h>
void main() 
{ 
    static int i = 1; 
    if (i <= 100) { 
printf("\n...Welcome To EduNews.Tech... ");
        printf("%d ", i++); 
        main(); 
printf("\n\n\n\n\t\t\tThankyou for Joining Us !");
    printf("\n\t\t\t!Regards EduNews !");
    } 
    //return 0; 
getch();
}

Program Output:

print numbers

I hope this post helps you to understand the “Print Numbers” on your screen and its implementation in C programming language.

Keep coding 🙂

Leave a Reply

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