c program to print n numbers without using loop

>> Tuesday, November 1, 2011


This program will print the n numbers without using any loop. Here we uses the concept of recursion. Lets See the program
to make clear view that how recursion works.


#include <stdio.h> #include <conio.h> void print(int p) {   if(p>0)   {     print(p-1);                    // recursive call;     printf("\n\n %d \t", p);   }   return; } int main() {   int n;   printf("enter the number\n\n");   scanf("%d",&n);                  // number to which you wnat to print   print(n);   getch();   return 0; }

Output:

C program to print n numbers, withou loop



0 comments:

Post a Comment

About This Blog

This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.

Share and Save