Thread: Help Please!

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    77

    Help Please!

    Please tell me if I am on the right track. This program takes 20 student # with grades and print them on the screen.
    Here is what I have until now. I am stuck at the display now. How do I get the user entered information and display it?.

    Code:
    #include <stdio.h>
    
    #define MAX_NUM_STUDENTS 20
    #define TRAILER -9999
    
    input (float* , int* );
    display (float* , int* );
    
    int main()
    {
      int student_num;
      float grade;
    
    	input (float* grade, int* student_num);
    	display (float* grade, int* student_num);
    
    }
    
    void input(float* grade, int* student_num)
    {
    
    	for (student_num < MAX_NUM_STUDENTS; student_num != TRAILER; student_num++)
    		{
    		printf ("Please enter up to %d students number.", MAX_NUM_STUDENTS);
    		scanf ("%d", &student_num);
    		}
    	for (grade < MAX_NUM_STUDENTS; grade != TRAILER; grade++)
    		{
    		printf ("Please enter up to %f grades.", MAX_NUM_STUDENTS);
    		printf ("Enter %d to signal end of data.", TRAILER);
    		scanf ("%f", &grades);
    		}
    }
    
    void display()
    
    	{
    		printf (" Student # with Grades:");
    		printf ("\t Student # \t Grades \n");
    		printf ("\t_________\t_______\n");
    }
    Thanks
    Last edited by jat421; 03-13-2005 at 01:41 PM.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    77
    Does that mean I am totally on the wrong track ?

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    You are on the right track you just need an array to store what the user enters. You could pass the array as the argument on your display function to get it done.
    When no one helps you out. Call google();

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    Errors in your program

    I think u shud first fix these errors ...

    Error C:\TMP.C 14: Expression syntax in function main
    Error C:\TMP.C 15: Expression syntax in function main
    Error C:\TMP.C 20: Type mismatch in redeclaration of 'input'
    Warning C:\TMP.C 22: Non-portable pointer comparison in function input
    Warning C:\TMP.C 22: Code has no effect in function input
    Warning C:\TMP.C 22: Non-portable pointer comparison in function input
    Warning C:\TMP.C 27: Non-portable pointer comparison in function input
    Warning C:\TMP.C 27: Code has no effect in function input
    Warning C:\TMP.C 27: Non-portable pointer comparison in function input
    Error C:\TMP.C 31: Undefined symbol 'grades' in function input
    Error C:\TMP.C 37: Type mismatch in redeclaration of 'display'



    VPD

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    77
    Thanks InvariantLoop

    VPD, Yea after I am finised passing the values to display() I will work on the errors :P

    Thanks

  6. #6
    Registered User coolshyam's Avatar
    Join Date
    Mar 2005
    Posts
    26

    Thumbs up The Program Done

    i dont know how you could display 20 values at the same time on the screen
    do look at the output generated by my program
    it's done using TurboC
    Code:
    #include <stdio.h>
    #include<conio.h>
    #define MAX_NUM_STUDENTS 20
    #define TRAILER -9999
    
    void input (float* , int* );
    void display (float* , int* );
    
    int main()
    {
      int student_num[20];
      float grade[20];
    
    	clrscr();
    	input (&grade,&student_num);
    
    	display (&grade,&student_num);
    	getch();
    
    	return 0;
    }
    
    void input(float *grade, int *student_num)
    {
    	int i;
    	for (i = 1;i != 20; i++)
    		{
    		printf ("Please enter up to %d students number.", MAX_NUM_STUDENTS);
    		scanf ("%d", &student_num[i-1]);
    		}
    	for (i = 1; i != 20; i++)
    		{
    		printf ("Please enter up to %d grades.", MAX_NUM_STUDENTS);
    		scanf ("%f", &grade[i-1]);
    		}
    }
    
    void display(float *grade,int *student_num)
    {
    	int i;
    	for(i = 1; i != 20; i++)
    	{
    		printf ("\n Student #%d with Grades:%d",&student_num[i-1],&grade[i-1]);
    		printf ("\t Student #%d \t Grades%d \n",&student_num[i-1],&grade[i-1]);
    		printf ("\t_________\t_______\n");
    	}
    }

    any questions any type in programming

    a ready made answer
    -----------------------------------------------------------------------------------
    FORTUNE FAVOURS THE BOLD!
    -----------------------------------------------------------------------------------

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    Quit posting non-portable turbo-c code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed