Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question c programming (triangles)

    [CODE]
    #include<stdio.h>

    void Instruction(){
    printf(" SHALOM!\n\n");
    printf("Did you know that there are different types and sizes of a triangle?\n\n");
    printf("If you don't I can take you there!!!!\n\n");
    printf("so seatback and relax...and let your finger work...\n\n");
    printf("You must first select the TYPE AND SIZE of triangle you want to execute (separated by space).\n\n");
    printf("[A] REGULAR\n\n");
    printf("*\n");
    printf("**\n");
    printf("****\n");
    printf("[B] INVERTED\n\n");
    printf("***\n");
    printf("**\n");
    printf("*\n");
    printf("[C] FACING OPPOSITE DIRECTION OF THE REGULAR\n\n");
    printf(" ***\n");
    printf(" **\n");
    printf(" *\n");
    printf("[D] INVERTED FACING OPPOSITE DIRECTION\n\n");
    printf(" *\n");
    printf(" **\n");
    printf(" ***\n");
    printf("[E] PRINT ALL 4 TRIANGLES (one below the other).");
    printf("SURPRISE! \n\n YOU HAVE THE MOST AMAZING TRIANGLE EVER!!!\n\n");
    printf("If you WANT to try again enter 1 otherwise enter 0\n\n\n");
    }
    int main() {
    Instruction();
    int x, y, size, g=0, k;
    int reg, inv,inv_face,opp;
    char choice;
    do {
    printf("\n\n Enter your CHOICE and SIZE of the triangle(separated by a space):");
    scanf("%c %d", &choice,&size);
    printf("\n");
    switch (choice){
    case 'A':
    reg = REGULAR(size);
    break;
    case 'B':
    inv = INVERTED(size);
    break;
    case 'C':
    opp = OPPOSITE(size);
    break;
    case 'D':
    inv_face = INVERTED_FACING(size);
    break;
    case 'E':
    reg = REGULAR(size);
    inv = INVERTED(size);
    opp = OPPOSITE(size);
    inv_face = INVERTED_FACING(size);
    break;
    }
    printf("\n Do you want to try again? [1-yes/0-no]:");
    scanf("%d",&k);
    printf("\n");
    }while (k>0);
    return 0;
    }

    int REGULAR(size){
    int x,y, reg;
    for (x=0; x<=size; x++) {
    for (y=0; y<x; y++)
    printf("*");
    printf("\n");
    }
    return reg;
    }

    int INVERTED(size){
    int x,y, inv;
    for (x=0; x<=size; x++) {
    for (y=size; y>x; y--)
    printf("*");
    printf("\n");
    }
    return inv;
    }

    int OPPOSITE(size){
    int x,y,g=0,opp;
    for (x=size; x>=1; x--) {
    for(y=1; y<=g; y++)
    printf(" ");
    g++;
    for (y=1; y<=x; y++)
    printf("*");
    printf("\n");
    }
    return opp;
    }

    int INVERTED_FACING(size){
    int x,y,inv_face;
    for (x=0; x<=size; x++) {
    for(y=size; y>x; y--)
    printf(" ");
    for (y=1; y<=x; y++)
    printf("*");
    printf("\n");
    }
    return inv_face;
    }

    this is my program... and i don't have any idea where i commit my mistake.

    please help me! (((

  • #2
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and i use code blocks 10.5 as my compiler.

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    and i don't have any idea where i commit my mistake.
    Do you get any errors?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no i haven't but only when i try it again..

  • #5
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Do you get any errors?
    no i haven't but only when i press 1 and i try it again...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •