Thread: Two questions :) don't know where to begin

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Lightbulb Two questions :) don't know where to begin

    Hey all,
    I have two questions I am working on for a lab. Could anyone post some code snippets (not asking to have my work done so feel free to add errors) for these two programs I am working on with school?

    1.)Write a program that puts 10 different initials into 10 elements of a single character array. Print the list forward with one initial on each line and backwards on the same line. Add correct printf() statements to print the values to the screen. Use appropriate messages to describe what is being printed.

    2.)Assume that a video store employee works 50 hours. She gets paid $7.25 for the first 40 hours; she gets time-and-a-half pay (1.5 times the regular rate) for the first 5 hours over 40; and she gets double-time pay for all hours over 45. Assuming a 28 percent tax rate, write a program that prints her gross pay, taxes, and net pay to the screen. Label each amount with appropriate titles (using string constants) and add appropriate comments in the program.

    -again just some ideas with grouping variables and equations would be GREATLY appreciated. I'm still green as a blade of grass

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    the first program is very basic, the second only slightly more difficult, study, using use your course materials/notes / textbook which i am sure you have been provided with or you have at least attended classes relating to the actual problems posed , then post some kind of an attempt, we can take it from there
    Last edited by rogster001; 02-25-2010 at 10:08 AM.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    "single character array" is a bit confusing. An array usually has multiple elements. Does it mean an array whose elements are each single characters?

    Printing such a list forward and backward means using loops (for, while, do type statements) to go in either directions and extract characters (initials?).

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by nonoob View Post
    "single character array" is a bit confusing.
    What? We all know what a character array is. "Single" in english means one -- as in, I would like a single potato chip. Who would be confused by that ("Well, maybe it means a kind of potato chip made from just one potato...")?

    @unbrknchane: since a single character array is such a simple thing, start by writing a program which uses a character array and printf. This is a slight variation on "hello world", which you may be familiar with.

    http://en.wikipedia.org/wiki/Hello_world_program
    A complete working "hello world" written in C is available in the article. Modify it to use a character array instead of a string literal:
    Code:
    char hw_ray[]="hello world";
    It's much easier if you post the snippets and we criticize
    Last edited by MK27; 02-25-2010 at 01:28 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    4
    thanks guys! figured it out....loops havent really been discussed as far as they should have. we had a few snow days but i found some good literature on it and i got it in on time. i'm more or less struggling with already knowing a few other languages (in a newb sense). just need to keep practicing but i got them turned in. anyone know of a good reference site for quick info?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  4. C++ test questions
    By Mister C in forum C++ Programming
    Replies: 9
    Last Post: 09-08-2002, 12:05 PM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM