Jump to content
Sign in to follow this  
syira86

Assgment C++

Recommended Posts

[b] salam....nk mntk ckit boleh tak..nak tanya pasal soalan C++ ini...saya tak dapat nak jawab...harap kwn2 dapat tolong

Write a C++ program to calculate the average of a set of grades and counting the number of failing test grades, the output are shown as following:-

How many grades will you be entering? 7
... Enter grade #1 : 93
Enter grade #2 : 63
Enter grade #3 : 87
Enter grade #4 : 65
Enter grade #5 : 62
Enter grade #6 : 88
Enter grade #7 : 76
Grade average = 76.29
Number of failures = 2[/b]

Share this post


Link to post
Share on other sites
soalan ko ni x jelas.markah fail brp?aku malas btl kalo buat keje soalan yg x jelas.coding ni aku assume markah fail bawah dr average.

[CODE]#include <iostream>

using namespace std;

void main () {

int index, sFail=0;
double tot=0, avg=0;
double* t;

cout<<"How many grades will you be entering? ";
cin>>index;

t = new double[index];

for (int a=0; a<index; a++) {
cout<<"Enter grade #"<<a+1<<" : ";
cin>>t[a];

tot = tot + t[a];
}

avg = tot / index;

for (int b=0; b<index; b++) {
if ( t[b] < avg )
sFail = sFail+1;
}

cout<<"Grade average = "<<avg<<endl;
cout<<"Number of failures = "<<sFail<<endl;
}[/CODE]

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...