Write a C++ program?

Write a C++ program that contains a structure named “Student” having two data members 1) Name2) CGPADeclare array of structure “Student” of size 10 .Populate this array by taking data from file inputFile.txt.File inputFile.txt contains Name and CGPA of the students for current semester. There is a single space between the Name and CGPA.Display the un-sorted list of students on screen. Compare the CGPAs of all the students and sort Student List with respect to CGPA in ascending or descending order.Display the sorted list of students, highest CGPA and lowest CGPA on screen and also write the result in File outputFile.txt with tab characters between the Name and CGPA.

5 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Sounds like a fun homework assignment for YOU TO DO YOURSELF.

  • 1 decade ago

    I'd use a spreadsheet instead of C++. I'd copy the text file into the spreadsheet. Then the data can be sorted easily just go to data and sort. If this is for a class your book will tell you the correct commands to input, sort the data and then output the data into a text file. I have never used C++ but in basic an array was a place to store data. I would think you could use input or a similar command to input the data from the file then use display or a similar command to show the file on screen. Then use sort or a similar command to sort ascending or descending. Then use display or a similar command. Then use write, output or a similar command to make the output file.

  • 5 years ago

    Why don't you just add a temporary variable? Ok, just thinknig about it, this works: (This will all be pseudo code because I can't recall C) Variables will be called var1 and var2. var1 = var1 + var2 var 2 = var1 - var2 var1 = var2 - var1 Each step being done after the previous one. Hope it helps.

  • 1 decade ago

    read a tutorial and do it yourself, it's really easy.

  • How do you think about the answers? You can sign in to vote the answer.
  • 1 decade ago

    how about in php?

Still have questions? Get your answers by asking now.