Thread: Can't figure out how to put make this program using a while loop instead of for loop

  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    13

    Question Can't figure out how to put make this program using a while loop instead of for loop

    So I got my program to print an inverted right angle triangle using asterisks but I cannot for the life of me figure out how to do it with while loops. This is what I've got as my for loop if that helps:

    Code:
    #include <stdio.h>
    
    
    main(){
    
    
         int i, j;
    
    
        for(i =1; i<=5; i++){
    
    
              for (j=5; j>=i; j--){
    
    
              printf("*");
    
    
    }
    
    printf("\n");
    
    }
        return 0;
    }
    Any help is greatly appreciated!

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 11-13-2013, 08:13 PM
  2. Help to figure out a loop
    By ZdravkoTsv in forum C Programming
    Replies: 16
    Last Post: 01-28-2012, 03:20 PM
  3. cant figure out where to put the loop....
    By seal in forum C Programming
    Replies: 2
    Last Post: 08-30-2005, 10:10 AM
  4. can't figure out a loop...
    By bcianfrocca in forum C++ Programming
    Replies: 7
    Last Post: 09-20-2004, 06:17 AM
  5. ahh i can't figure out this loop
    By blindleaf in forum C Programming
    Replies: 1
    Last Post: 03-18-2003, 09:42 AM

Tags for this Thread