Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

12 May 2013

C PROGRAM TO PRINT NUMBERS 1 TO N WITHOUT USING LOOPS

C PROGRAM TO PRINT NUMBERS 1 TO N WITHOUT USING LOOPS


#include<stdio.h>
void print_numbers(int,int); //declaring function definition
main()
{
  int n;
  printf("\n *** C PROGRAMS BLOG ***");
  printf("\n >>> Program to print numbers 1 to n without using Loops <<<");
  printf("\n\n Enter the value of n: ");
  scanf("%d",&n); //taking value of n as input from user
  print_numbers(1,n); //calling the function
  getch();
}
void print_numbers(int i,int max)
{
 printf("%3d\t",i);
   if(i<max)
   {
    //calling function recursively
    print_numbers(++i,max);
   }
   return;
}

Sample Output :



26 comments:

  1. Good
    Here is a link for C/C++ programs and pointer programs. This may be useful for you.

    C/C++ Programs

    ReplyDelete
  2. BA/BCOM/BSC/BBM/COMPUTER/IT/DIPLOMA RESUMES
    http://topjobssearchblog.blogspot.in/

    ReplyDelete
  3. Computaholics Provide Programming Example of C,Java program,Opengl program,Hadoop fs commands & Tutorial,Cse Engineering project
    http://www.computaholics.in/
    http://www.computaholics.in/2015/12/hdfs.html
    http://www.computaholics.in/2015/12/mapreduce.html
    http://www.computaholics.in/2015/11/hadoop-fs-commands.html
    http://www.computaholics.in/2016/01/internet-of-things.html

    ReplyDelete
  4. Thanks for sharing ur valuable inforamtion ,we also provide C programming languages classes in bangalore,visit : <a href="http://www.aptechyelahanka.com/c-courses-bangalore/>Aptech computer education</a>,my tage are : C training bangalore,C courses bangalore,C classes bangalore,C institute bangalore,C coaching centers bangalore,C programming institute in bangalore,C programming classes in bangalore

    ReplyDelete
  5. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete
  6. thanks for this post its really help me in coding by the way did you know what are the datatypes in c programming language

    ReplyDelete
  7. Thank you for sharing very informatics and useful post about very useful info.... Turbo-IVP (Invoice Validation Portal) and Turbo eSigner

    ReplyDelete
  8. Thanks for sharing nice information. I am really looking for these kind of blog. Keep sharing. c programming classes in pune

    ReplyDelete
  9. learn c programming free tutrioal the link is: beginerinprogramming.blogspot.com

    ReplyDelete
  10. #include
    void sum(int,int); /*declaring prototype of function*/
    void main()
    {
    int a,b,c;
    printf("\n Enter the two numbers : ");
    scanf("%d %d",&a,&b); /* taking two numbers as input*/
    c = sum(a,b); /* calling function,
    *the value returned by the function is stored in c */
    printf("The sum of two numbers is : %d",c);
    getch();
    }

    void sum ( int num1,int num2)
    {
    int result; /* defining variable, its scope lies within function */
    result = num1 + num2 ; /*adding two numbers*/
    printf ("sum=%d",result);
    }

    what is error in this program. i want to add 2 number using calling funtion with no return.

    ReplyDelete
    Replies
    1. Hi,
      c = sum(a,b); this line is wrong, you sum function is not returning anything, then you cannot store any value in c varialble

      Delete

  11. very useful info, and please keep updating........
    Best Online Software Training

    ReplyDelete
  12. good logic and help me a lot in logic building.even we can do the same program with the help of recursion. http://onlinedigitaltechnology.com/control-structure/

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Thank for your kind Information, keep posting and do post something about Embedded System Programming also.

    ReplyDelete
  15. Thank for your kind Information, keep posting and do post something about Embedded System Programming also.

    ReplyDelete
  16. Madaalarqam we provide best electronic trade platforms for consumer and reseller. We also develop all types of Programming applications

    ReplyDelete
  17. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital informationC Programming Training in Chennai

    ReplyDelete
  18. very nice..post.
    https://shayarihindishayari.com/

    ReplyDelete
  19. hi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up. best sap simple finance online training institute in hyderabad

    ReplyDelete
  20. thank you for sharing useful info
    web programming tutorial
    welookups

    ReplyDelete