473,412 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

anyone can help me out to convert it to c++. i am a fresh student .

Initialize total to zero

Initialize counter to zero

Input the first grade

while the user has not as yet entered the sentinel

add this grade into the running total

add one to the grade counter

input the next grade (possibly the sentinel)

endwhile



if the counter is not equal to zero

set the average to the total divided by the counter

print the average

else

print 'no grades were entered'

endif
Nov 6 '20 #1
2 3272
dev7060
636 Expert 512MB
  • initialize/set -> assignment operator
  • input -> input stream object
  • 'while the user' -> loop
  • add -> '+' operator
  • print -> output stream object
  • if -> if conditional
  • use += with 'total'
  • average (should be float/double) -> (sum of all values)/(total number of values)
It's mentioned where the loop or if block ends. Boolean conditions are stated as well.
Nov 6 '20 #2
AjayGohil
83 64KB
Hello,

you can refer following syntax for your program:

Initialize total and counter as follow

Expand|Select|Wrap|Line Numbers
  1. int total=0;
  2. int counter=0; 
  3. int grade=0;
  4. int average=0;
for input grade use cin

Expand|Select|Wrap|Line Numbers
  1. cin>>grade;
for loop use while loop
Expand|Select|Wrap|Line Numbers
  1. while (sentinel) {
  2.  cin>>grade;
  3.  total=total+grade;
  4.  counter=counter+1;
  5. }
  6. if(counter!=0)
  7. {
  8. average=total/counter;
  9. cout<<"Average"<<average;
  10. }
  11. else
  12. {
  13. cout<<"No grades were entered";
  14. }
  15.  
  16.  
Nov 11 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: J. Nielsen | last post by:
I'm not a programmer and I don't have the time and energy to start learning right now So I need some help. Let's say I have made an HTML Table (consisting of three columns and six rows). In each...
5
by: irin07 | last post by:
hello... i just learn how to use php,can anyone help me about how to edit database using php,plzz....i need urgently and i really blank about this. this the database dbhelpdesk table...
0
by: derik | last post by:
04:57:10 172.16.30.239 GET /name/Admin.aspx 200 04:57:10 172.16.30.239 GET /name/Admin_topbanner.aspx 200 can any one help me in delimiting this these text should be placed in a data grid...
3
by: Cara83 | last post by:
Hi everyone, I am only new to this Perl programming world and I am having problems with the script I am writing. The program is supposed to search a number of specified directories for files...
0
by: moh5658 | last post by:
----- =_part_411 31725616.1233263577635 content-type;multipart/alternative;boundary="----=_part_412 32512809.1233263577635"------=_part_412 32512809.123326 can anyone help i recieved a text...
0
by: mohamed Reda | last post by:
Thanks for your great help you offer through this nice form. My problem is in encryption and decryption using RSA, in my project I need to encrypt some string using the public key and send the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.