Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
C#
#include <iostream>

using namespace std;

const int positive = 5;

int main ()
{
     int n;
     cout << "Enter the number of students, and grades are separated by spaces:";
     cin >> n;
     int * p = new int [n];
     for (int i = 0; i < n; i++) p [i] = 0;
     int sum = 0, Hmany = 0 failed = 0;
     for (int i = 0; i < n; i++)
     {
         if (p [i] < positive)
         {
             if (!failed) cout << "students did not write:";
             failed ++;
             cout << '' << i;
         }
         sum + = p [i];
         Hmany ++;
     }
    cout << endl << n-failed << " studens passed, " << failed << " failed, groups average - " << (double)sum/Hmany << endl;
    return 0;
}
Posted
Updated 9-Dec-14 12:29pm
v4
Comments
ZurdoDev 9-Dec-14 14:32pm    
Where are you stuck?
CPallini 9-Dec-14 16:01pm    
It is an almost trivial task...
Andreas Gieriet 9-Dec-14 18:26pm    
What knowledge is missing?
- cin/cout --> Console.WriteLine.../Console.ReadLine.../int.TryParse...?
- int * p = new int[0] --> how to create an int array of n elements?
- replace #include/using namespace... by suitable usings?
- pack all into a class?
- adjust main to match the C# style?
Andi
Member 11298492 10-Dec-14 0:32am    
Thanks... Done it :)

1 solution

No.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
Andreas Gieriet 9-Dec-14 18:22pm    
Of course a 5 - what else? Speak up those who vote a 1!
Cheers
Andi
RedDk 9-Dec-14 19:10pm    
I confess.

(The man puts code in his tips!)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900