Program to print numbers from 1 to 100 without using loops


Default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Write a program to print numbers from 1 to 100 without using loops
// Eg: 1 2 3.... 99 100

 
#include <stdio.h>
int numbers(int );
int main(){
    printf("%d",numbers(1));
    getch();
}
int numbers(int n){
    if(n==100){
         return n;
    }
    printf("%d ",n);
    return numbers(n+1);
}

No comments:

Post a Comment