🔒 Closed Turbo C - Draw pattern using turbo c

Status
Not open for further replies.

negro_lans

Eternal Poster
baka po may nakakaalm kung panu sya pa draw ? ung kalahati lang kc ang na draw ko ...

need to draw :

mahirap.webp


my output :

oooooo
ooooo
oooo
ooo
oo
o

Eto po ung Code ko :

#include <stdio.h>
#include <conio.h>
int main(){
for(int a=5; a >=1; a--)
{
for(int b=1; b<=a; b++)
{
printf("o");
{
printf("\t");
}
}
printf("\n");
}
getch();
}
--------------------------------------------------------------------

salamat po sa tutulong in advance ..
 
Easy:

C:
#include <stdio.h>
#define SIZE 10

int main(void){
    int i=0;
    printf("\nProgram that draws a triangle\n");
    printf("-----------------------------\n\n");
    for(; i<SIZE; i++) {
        for(int x=SIZE; x>i; x--) {
            printf("o");
        }
        for(int z=0; z<i+i; z++) {
            printf("+");
        }

        for(int x=SIZE; x>i; x--) {
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    return 0;
}

Btw, get away from ancient compiler. Use either GCC, Clang or MSVC.
 
Easy:

C:
#include <stdio.h>
#define SIZE 10

int main(void){
    int i=0;
    printf("\nProgram that draws a triangle\n");
    printf("-----------------------------\n\n");
    for(; i<SIZE; i++) {
        for(int x=SIZE; x>i; x--) {
            printf("o");
        }
        for(int z=0; z<i+i; z++) {
            printf("+");
        }

        for(int x=SIZE; x>i; x--) {
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    return 0;
}

Btw, get away from ancient compiler. Use either GCC, Clang or MSVC.
Salamat po .. un po kc ang tinuturo ngaun sa school namen .. ako nalang po ang mag coconvert nito .. maraming salamat po ng madame . test ko po
 
You already made the half. All you need to do is to reverse the logic for the other half. Anyways, I have covered the exact problem few months back, you can navigate through the past threads, mas marami pang triangle ang covered dun written in C#. You can easily rewrite it to C++ to comply your language requirement.
 
Status
Not open for further replies.

About this Thread

  • 11
    Replies
  • 718
    Views
  • 6
    Participants
Last reply from:
aa1012

Trending Topics

Online now

Members online
1,062
Guests online
844
Total visitors
1,906

Forum statistics

Threads
2,274,941
Posts
28,959,487
Members
1,233,488
Latest member
lea11sales
Back
Top