how does increment & for loops work in c?

Status
Not open for further replies.

Faun

Wahahaha~!
Staff member
clmlbx said:
I missed one class and then to I want to complete this assignment to make a good impression :D :D .( my prevoious was not good :( )


nothing more, and here guys are to help so I asked.....:(
put ur brain into the subject, logic is all u need.

These things are the simplest ones, the real nightmare is advanced data structures. So save ur questions for that time.

U posted now without CAPS on :D
 

QwertyManiac

Commander in Chief
All you have to do is search.

What you are asking for is left justification I think, so read up on the printf function at CPlusPlus, read the flags part:
*www.cplusplus.com/reference/clibrary/cstdio/printf.html
 
I think the only reason this thread has these many replies is because this being a simple question, everyone can "prove" that he/she is a programmer :lol:
 
OP
clmlbx

clmlbx

Technomancer
ok guys whatever you say ?

I did not try and tomorrow morning is my class so can anybody give e the code ?

please......please

*****
-****
--***
---**
----*

and

----*
---**
--***
-****
*****

"-" = spaces

please some one give me code
 

QwertyManiac

Commander in Chief
Don't ask code again, its time you set into dusted off your brain-cobwebs and put it to some use!

Code:
#include<stdio.h>

int main(void)
{
    int i,j;
    char a='*';
    for(i=6;i>0;i--)
    {
        for(j=6;j>i;j--)
        {
            printf("  ");
        }
        
        for(j=1;j<i;j++)
        {
            printf("%c ",a);
        }
        printf("\n");
    }
    
    printf("\n");
    
    for(i=1;i<6;i++)
    {
        for(j=5;j>i;j--)
        {
            printf("  ");
        }
    
        for(j=1;j<i+1;j++)
        {
            printf("%c ",a);
        }
        printf("\n");
    }
    
    printf("\n");
    return 0;
}
Outputs as:
Code:
As you expect.
 
OP
clmlbx

clmlbx

Technomancer
thank you very much

thanxx a lotttttttt *gigasmilies.googlepages.com/1.gif*gigasmilies.googlepages.com/36.gif
 
Status
Not open for further replies.
Top Bottom