Struct student query

PHOTO EMBED

Mon Jun 10 2024 11:07:09 GMT+0000 (Coordinated Universal Time)

Saved by @meanaspotato #c

#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;
}
content_copyCOPY

Objective Complete the given incomplete C source code by filling in the instructions at each TODO comment. Your program should query the user for a student's details and then display them. Main Function Declares a variable query of type struct Student. Calls the query_student function to populate the query variable. Prints out the details of the query variable in the specified format. Function query_student(void) Declare a local variable of struct Student. Use printf and scanf to get the first name, last name, and stream code from the user. Return the populated local struct Student variable to main(). For example: Input Minh Nguyen 12 Result Input first name: Input last name: Input stream code: Minh Nguyen is in stream 12.