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 :



40 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. 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
  6. Thank you for sharing very informatics and useful post about very useful info.... Turbo-IVP (Invoice Validation Portal) and Turbo eSigner

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

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

    ReplyDelete
  9. #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
  10. 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
  11. This comment has been removed by the author.

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

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

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

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

    ReplyDelete
  16. Thank you so much for sharing this amazing blog with us. Anyone who are searching for more, free training's like C, Python, Java, Asp.Net, Nodejs and more programming languages please contact Nareshit.
    NodeJS Online Training

    ReplyDelete
  17. Eumaxindia specializing in Radio Advertising like suryan fm,redfm,big92.7fm,radio city,hello106.4fm.we are provides all types of online radio advertising.

    Creative radio ads Chennai

    ReplyDelete
  18. This is a nice blog related to C program anyone wants to Learn about how does the program process in the memory, what is debugging etc. Refer->https://solveprogram.com/

    ReplyDelete
  19. Thanks admin for the post, Its really a nice post and Looking for more blogs like this. Please stay updated..!

    Learn Entity Framework

    ReplyDelete
  20. Thanks for the programs. I read theory from here but looking for programs.
    Thanks for providing the programs.

    ReplyDelete
  21. Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
    Node JS Training in Chennai
    Perl Training in Chennai

    ReplyDelete
  22. Great Post and valuable...This post is so informative...

    ReplyDelete
  23. This post is so helpfull and informative.keep updating with more information...
    Hacker Interface
    Hacking Technology

    ReplyDelete

  24. Thank you, This was the best and most interesting course. please continue to share your thoughts.

    RPA Training in Chennai
    RPA Training Online
    RPA Training In Bangalore

    ReplyDelete
  25. React.js offers a faster development environment, and its very easy to use. Learn them without taking care of too many setups, when you are developing apps by serving HTML files.
    Learn How to Use Reactjs Cdn

    ReplyDelete