Thread: to amend the C program

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    12

    to amend the C program

    Based on the program defined in Listing 2, i am required to amend the C program to introduce a function, which implements the behaviour defined from line 5 to line 10. The function should be declared as follows:
    It should be called input,
    It should take one argument a reference to a Student struct object and has void return type.
    It should be called from the main() function.
     The function prototype and implementation should be contained in the same file as the
    main() function.
     For this question you are required to write the C code for the function declaration, definition and the amended main function.

    CAN ANYBODY HELP TO SOLVE THIS PLEASE??

    Last edited by AG1; 06-17-2012 at 11:12 AM.

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    12
    the code is as follow: Listing 2
    Code:
    Line # Code
    1 #include <stdio.h>
    2 int main() {
    3 char studentName;
    4 double assignment, exam, unitMark;
    5 printf("Enter student name: \n");
    6 scanf("%s", studentName);
    7 printf("Enter assignment mark: \n");
    8 scanf("%f", &assignment);
    9 printf("Enter exam mark: \n");
    10 scanf("%f", &exam);
    11 unitMark = assignment*0.4 + exam*0.6
    12 printf("Student name: %s has grade: %f \n", studentName, unitMark);
    13 return 0; }
    Last edited by AG1; 06-17-2012 at 11:00 AM.

  3. #3
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Have you read up on functions? What exactly do you need help with? Line 3 studentName should be an array.

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    12
    hey.. thanks for ur quick reply...
    i have to edit the code according to the 5 bulleted points mentioned above. do u know how to do that? If u can than it will be great and i'll be very thankful to you..

  5. #5
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    This site has a strong no homework policy and encourages you to give it a try first. Try your best to get some down, and when you get stuck come here and post your problem. Everyone here will be more than happy to help. I suggest you start with your prototype first, since you already know the name and the return type now you just need to figure out what parameters you need to pass it.

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    12
    its not a homework!! its a sample example which im trying to solve..

  7. #7
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Regardless, you still have to attempt it. no one is going to give you the answers if you do not show any kind of effort.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-16-2010, 10:17 AM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM