#include <stdio.h>
struct Student
{
char first_name [20];
char last_name [20];
int stream_code ;
};
struct Student query_student(void)
{
// TODO: Declare a local Student variable.
struct Student student;
printf("Input first name: \n");
// TODO: Scan for user input...
scanf("%s",student.first_name);
printf("Input last name: \n");
// TODO: Scan for user input...
scanf("%s",student.last_name);
printf("Input stream code: \n");
// TODO: Scan for user input...
scanf("%d",&student.stream_code);
// TODO: Return the local Student variable.
return student;
}
int main(void)
{
struct Student query;
query = query_student();
printf("%s ", query.first_name);
printf("%s ", query.last_name);
printf("is in stream %d.", query.stream_code);
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter