Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 C program help
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cwarrior




PostPosted: Sun Mar 29, 2009 9:49 pm   Post subject: C program help

Basically i have to write a program that will draw a face. like this one:

code:
   
         hhh
     hhhhhhhhh
  hhh           hhh
hhhh  O   O  hhhh
  hhh     o     hhh
   hh   \__/   hh
     h            h
     hhhhhhhhh


and i have to write the inside of the face in a function that takes 1 to draw the eyes 2 to draw the nose and 3 to draw the mouth
This is what i got:

code:

#include <stdio.h>
face(int line);
main()
{
char c = 'h';

printf("%7c%c%c \n",c,c,c);
printf("%4c%c%c%c%c%c%c%c%c \n",c,c,c,c,c,c,c,c,c);
printf("%2c%c%c%8c%c%c \n",c,c,c,c,c,c);

printf("%c%c%c%c%c%8c%c%c%c \n",c,c,c,c,face(1),c,c,c,c);
printf("%2c%c%c%8c%c%c \n",c,c,c,c,c,c);
printf("%3c%c%8c%c \n",c,c,c,c);
printf("%4c%8c \n",c,c);
printf("%4c%c%c%c%c%c%c%c%c \n",c,c,c,c,c,c,c,c,c);


}
face(int line)
{
 
  if(line == 1)
    printf(" o   o ");
  else if (line == 2)
    printf("   o   ");
  else if (line == 3)
    printf("  -   ");
}                    


I do not know how to put the function face in the main so that it displays each line properly. As you guys see I have done work I just need help with that. Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
Unforgiven




PostPosted: Mon Mar 30, 2009 6:34 pm   Post subject: RE:C program help

I'm a little unclear on what you're asking. I thought you meant you didn't know how to call a function in main(), but you did, once.

Can you explain a little more? Or, did you just mean you weren't sure *where* to call it?
cwarrior




PostPosted: Mon Mar 30, 2009 6:50 pm   Post subject: Re: C program help

yes where do I call it so that it prints the eyes with 1, the nose with 2, and the mouth with 3?
rdrake




PostPosted: Tue Mar 31, 2009 10:30 am   Post subject: RE:C program help

Isn't there already this exact same question asked in a different forum? You've already done this once. Just stick to the single topic in the C forum where it belongs.

Another warning for you.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: