
November 8th, 2012, 09:52 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 8
Time spent in forums: 1 h 30 m 25 sec
Reputation Power: 0
|
|
|
Output in C
I've finished an assignment and it compiles and runs but when I run it I'm having some issues with my output. In my show_class function I have it show the name, age, and gpa but when I run it the line with that information looks like this:
Code:
Enter name of student:melissa
Enter age of student:22
Enter GPA of student:2.22
name:melissa
/nage:22/nGPA:2.220000/n
Here's my code:
Code:
3 #include<stdio.h>
4 struct Person
5 {
6 char name[100];
7 int age;
8 float gpa;
9
10 };
11 void fill_person(struct Person* per)
12 {
13 printf("Enter name of student:");
14 fgets(per->name,100, stdin);
15 printf("Enter age of student:");
16 scanf("%d", &per->age);
17 printf("Enter GPA of student:");
18 scanf("%f", &per->gpa);
19
20 }
21 void show_person(struct Person* per)
22 {
23 printf("name:%s/n", per->name);
24 printf("age:%d/n", per->age);
25 printf("GPA:%f/n",per->gpa);
26 }
27
28
29
30 int main()
31 {
32
33 struct Person per;
34 fill_person(&per);
35 show_person(&per);
36 return 0;
37 }
Anybody know how to fix this?
|