Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program so that a user can enter first and last name of students. Generate email address and identification number of the students.

Write a C program so that a user can enter first and last name of students. Generate email address and identification number of the students. Search by last name and if a match is found display the email address and identification number of the student in the console. Use a function enter() to take the information from the user and generate email address and identification number. Use a search() function to search for the student. Note: strcmp() in string.h can compare between two string. Update program with delete and sorting(insert) capabilities.

#include #include #include

typedef struct student { char first_name[30]; char last_name [30]; char email [50]; int id; } student;

student *enter()

{ int i; student *students = (student *) malloc(3 * sizeof(student)); char domain[] = "@miners.utep.edu"; for(i = 0; i < 3; ++i) { printf("Enter student %d details ", i+1); printf("First name: "); scanf("%s", students[i].first_name); printf("Last name: "); scanf("%s", students[i].last_name); students[i].email[0] = 0; strcat(students[i].email, students[i].first_name); strcat(students[i].email, students[i].last_name); strcat(students[i].email, domain); students[i].id = i + 1; } return students; }

void search(student *students) { char name[30]; int i; printf(" Enter last name to search: "); scanf("%s", name); for(i = 0; i < 3; ++i) { if(strcmp(students[i].last_name, name) ==0) { printf("First name: %s ", students[i].first_name); printf("Email: %s ", students[i].email); printf("ID: %d ", students[i].id);

} } }

int main() { student *students = enter(); search(students); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

What is a SAS 70 report? What is its purpose? Who has access to it?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago