Thread: Writing an array program

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    7

    Writing an program two function

    Write the program with at least two functions to solve the following problem. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases whick would be 8%.

    Code:
    /* calculate salary for faculty members*/
    
    #include <stdio.h>
    
     int main (void)
     
     // local declarations 
     double presSal;
     double rateincre;
      int salary;
      int increase;
      
     // statements 
     printf ("enter your salary:       "); 
     scanf ("%lf", %presSal);
     printf (" enter rate increase:   ");
     scanf ("%lf", %rateincre);
      
      return 0;
      // main
    This is what I wrote so far, am I on the right track?
    Last edited by intimidator; 04-24-2011 at 12:38 PM.

  2. #2
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Is the pay increase supposed to be a constant? The way you described the program made it seem like it should be constant.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Location
    Las Vegas
    Posts
    66
    Hi intimidator. You are on the right track in that you need to ask the user to input some values. You just need a bit of refinement to get this to first compile, and then to function as you'd like.

    If your assignment is to use an array, you of course need to declare one. Arrays are usually processed with loops, so you need one of those, too. Double-check the syntax of your scanf function - you have a problem there. And of course, the biggest problem is that this most basic code can't compile, because you have not defined a code block for the main() function using curly braces...

    Kevin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing to my 2D Array
    By qwertysingh in forum C Programming
    Replies: 0
    Last Post: 04-12-2009, 01:16 PM
  2. Writing to a 2D array
    By qwertysingh in forum C Programming
    Replies: 3
    Last Post: 03-12-2009, 07:24 AM
  3. writing an array of bit-values
    By damansternpak in forum C Programming
    Replies: 2
    Last Post: 07-16-2007, 11:31 PM
  4. writing an array
    By RedZippo in forum C++ Programming
    Replies: 1
    Last Post: 04-11-2004, 02:47 AM
  5. Replies: 5
    Last Post: 11-19-2002, 09:36 PM