[Java] Make triangle with the special char * without using Loops!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: [Java] Make triangle with the special char * without using Loops!!!

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    [Java] Make triangle with the special char * without using Loops!!!

    Hello,

    i want to make a triangle without the use of loops(For,while,do while etc)

    For example Lets say that i give as input the number 4. The output must be:

    *
    * *
    * * *
    * * * *

    Its very easy using loops but without?!

  2. #2
    Join Date
    Nov 2011
    Posts
    1

    Able to solve it using Recusrion

    //Devendra - 9762114222
    //Mail me at - dev4developer@yahoo.co.in

    #include <stdio.h>
    #include <conio.h>

    void print_output(int);
    void print_star(int);

    int main(){
    int input = 0;

    clrscr();
    printf("Enter input:");
    scanf("%d", &input);

    print_output(input);
    getch();
    return 0;

    }

    void print_output(int n){
    static int i =1;
    if(i> n)
    return;
    else{
    print_star(i);
    printf("\n");
    i++;
    print_output(n);
    }

    }

    void print_star(int n){

    if(n==0)
    return;
    else{
    printf("*");
    n--;
    print_star(n);
    }

    }

Similar Threads

  1. Gradebook program
    By [gx]Shadow in forum Java
    Replies: 5
    Last Post: 10-25-2006, 10:20 PM
  2. Replies: 8
    Last Post: 04-24-2006, 10:00 AM
  3. Re: MAKE $$$$$$$$$$ FAST THIS REALLY WORKS
    By Mark Campisi in forum .NET
    Replies: 0
    Last Post: 07-14-2002, 04:05 PM
  4. How do I make a special link?
    By Robert Gelb in forum Enterprise
    Replies: 1
    Last Post: 05-10-2000, 03:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center