GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Mar-2005, 06:02
Bubba Bubba is offline
New Member
 
Join Date: Mar 2005
Posts: 2
Bubba is on a distinguished road
Angry

Help with simple math table program (was a SIMPLE program)


Hi,
I started C programming 3 weeks ago, we had three four hour lessons, I am amazed how some people lack teaching skills or have any concern for students who like myself have other subjects to study for. I am not dumb and I normally pick up things quickly but I must say that I have learned more from internet then what I have picked up in the class. OK, ok, I just had to let a little bit of hot air out, it's all because of his poor teaching techniques!

I need someone to help me with this problem, I would prefer if someone gave me every second line so that I can work out anything in between!

I was given this:

CPP / C++ / C Code:
#include <stdio.h>
#include <conio.h>
main()
{
    int i,j;
    clrscr();
    for (i=1; i<13; i++)
  {
        for ( j=1; j<13; j++ )
                 printf ("%4d", i*j);
        printf ("\n");
  }
   return (0);
}
Now this is the assignment:

Write a program to modify the "tables" program, so that it prints out a table appropriate to an operator entered from the keyboard by the user. The program must be menu-driven and accept t, %, -, *, / , as inputs. The table must stay on the monitor screen until the user strikes a key and when upon control is passed back to the menu. To exit, the user must enter "Q".

It's as simple as that, can anyone help?

Bubba
Last edited by LuciWiz : 08-Mar-2005 at 07:31. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 08-Mar-2005, 23:06
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Start a while() loop that exits when "input" is 'Q'
Display your menu, accept the character.
In a switch() block, test the character and process it accordingly

That's about as much as I can tell you since I have no idea what 't' and '%' would do.

Also, read the note from LuciWiz at the bottom of your post.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #3  
Old 09-Mar-2005, 06:59
Bubba Bubba is offline
New Member
 
Join Date: Mar 2005
Posts: 2
Bubba is on a distinguished road
Angry

I assume "t" stands for "to be displayed on one line and "%" some mathematical function. Sorry guys I'm still beating my head against the wall as for what has to be placed where! Are you saying to continue with while () loop just above the "return ()" and then continue with the switch () block?

Sorry I feel we are nowhere near the stage to be able to write something like this! I'm still having problems with getting use to jargon and terms which we barely touched in the class.
Anyhow I know I'll get there one way or other, certainly not with his mechanical approach. I'd like to hit him with same approach or see someone do that to him just to see how smart he is!

LuciWiz, what does this mean? "Please insert your C code between
CPP / C++ / C Code:
 & 
tags."
I thought it was in the C & C++ forum? :-x

Bubba
  #4  
Old 09-Mar-2005, 13:40
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by Bubba
I assume "t" stands for "to be displayed on one line and "%" some mathematical function.
LuciWiz, what does this mean? "Please insert your C code between
CPP / C++ / C Code:
 & 
tags."
I thought it was in the C & C++ forum? :-x

Bubba

I would assume that you mis-copied the assignment, and that it should be '+', not 't'.

Then the assigment seems to be to make a program that lets the user enter an operator: +, %, -, *, or /.

Then create a table like the one in the example. Did you compile and run the example? It shows a table with each table entry equal to i*j, where i is the row and j is the column, and i and j go from ... to ... (you figure it out or print it out).

Your assignment seems to be to create a table where each table entry is obtained by integer arithmetic and is either i+j, or i%j or i-j or i*j or i/j, depending on user input. Then continue asking the user to enter the desired operator, and print the table for that operation, until the user enters 'Q'.

Perhaps one of the points of the exercise is to let you see how the operators work. If you don't understand integer division, or integer modulus, look at your output (or read the text).

Oh, yeah, about the code tags (lots of people don't understand at first).
Before the first line of your code, put [ c ] (don't put any spaces between the brackets and the 'c').

After the last line of your code, put [ /c ] (without any spaces).

Use the "Preview Post" button before you submit the reply, and you will see the code with C syntax highlighted. This helps everyone see a little more clearly what the heck the code is. (It's also prettier.)

Regards,

Dave
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 14:30
simple graphics program on linux nkhambal C Programming Language 2 09-Mar-2005 13:57
Help with a simple program matthewbarr C Programming Language 3 10-Feb-2005 11:08
Help with a simple program. bluedragon27 C Programming Language 1 16-Nov-2004 16:40
How to write simple program like ........? laputa9000 C++ Forum 3 29-Oct-2003 13:09

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:09.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.