Question

Write a complete C++ program that constructs an array A of 10 elements of type Student....

Write a complete C++ program that constructs an array A of 10 elements of type Student. The type Student is a structure of two fields, the first field of type int represents the ID of the student the second field of type float represents the grade of the student. The program contains the following functions:

1- A void function input that enters the elements in the array.

2- A void function output that displays the elements of the array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include<iostream>
using namespace std;
struct student
{
   int Id;       //declaring id of type int
   float grade;       //decalring grade of type float
   inputData()       //dunction defination to the inputing data
   {
       cout<<"enter id of student ";
       cin>>Id;       //inputiing id
       cout<<"enter grade of student";
       cin>>grade;       //inputing grade
       cout<<endl;
   }
   outputData()       //function defination to the output daat
   {
       cout<<"ID is :"<<Id<<endl<<"grade is :"<<grade<<endl;
   }
};
int main()
{
   struct student s[10];       //creating array of student of 10 size
   for(int i=0;i<10;i++)
   {
       cout<<"enter student data:"<<i+1<<endl;
       s[i].inputData();       //function call
   }
   for(int i=0;i<10;i++)
   {
       cout<<"student data :"<<i+1<<endl;;
       s[i].outputData();       //function call
   }
}

OUTPUT:

enter student data:1
enter id of student 101
enter grade of student25.36

enter student data:2
enter id of student 102
enter grade of student45.21

enter student data:3
enter id of student 103
enter grade of student78.26

enter student data:4
enter id of student 104
enter grade of student45.36

enter student data:5
enter id of student 105
enter grade of student89.36

enter student data:6
enter id of student 106
enter grade of student45.00

enter student data:7
enter id of student 107
enter grade of student75.00

enter student data:8
enter id of student 108
enter grade of student55.99

enter student data:9
enter id of student 109
enter grade of student82.12

enter student data:10
enter id of student 110
enter grade of student78.12

student data :1
ID is :101
grade is :25.36
student data :2
ID is :102
grade is :45.21
student data :3
ID is :103
grade is :78.26
student data :4
ID is :104
grade is :45.36
student data :5
ID is :105
grade is :89.36
student data :6
ID is :106
grade is :45
student data :7
ID is :107
grade is :75
student data :8
ID is :108
grade is :55.99
student data :9
ID is :109
grade is :82.12
student data :10
ID is :110
grade is :78.12

--------------------------------
Process exited after 71.31 seconds with return value 0
Press any key to continue . . .

screenshot:

Add a comment
Know the answer?
Add Answer to:
Write a complete C++ program that constructs an array A of 10 elements of type Student....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Write the functions needed to complete the following program as described in the comments. Use the...

    Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80. /* File: course.cpp A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course.  The functions read() and write() are defined for the structure student.   Information about a course is stored as a...

  • 8. (15 marks) Write a complete C program, which uses an array of structures and two...

    8. (15 marks) Write a complete C program, which uses an array of structures and two user defined functions. The program deals with a library database. The program will ask the user to input required information about each book and store it in a structure in a user defined function called get info. The second user defined function display_info will display database information on the screen. The output should look as follows: Book Title Book ld 123456 C Programming 10...

  • In C language Write a program that includes a function search() that finds the index of...

    In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...

  • Write a c program that finds the uncommon elements from two array elements using pointers only...

    Write a c program that finds the uncommon elements from two array elements using pointers only . For example : Enter the length of the array one : 5 Enter the elements of the array one: 9 8 5 6 3 Enter the length of the array two: 4 Enter the elements of the array two: 6 9 2 1 output: 8 5 3 2 1 void uncommon_ele(int *a, int n1, int *b, int n2, int *c, int*size); The function...

  • Write a C program convert.c that converts each number in an array by the sum of...

    Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you...

    C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...

  • Write a C++ function that prints an array, skipping over a number of elements. Use the...

    Write a C++ function that prints an array, skipping over a number of elements. Use the following header: void printArraySkip(int array[], int elems, int skip) { } Where 'array' is an input array of 'elem' integer elements, and 'skip' is the number of elements to skip over. For example, if the function is called like this: int array[6] = { 5, 7, 11, 12, 18, 19 }; printArraySkip(array, 6, 2); The output would be: 11 19 in c++. Thanks

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT