473,382 Members | 1,400 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,382 software developers and data experts.

help urgent

how do you use the if function and how would one declare its values, example for a grading system for school

#include (iostream)

using namespace std;

char letter-grade;


cout<<"enter grade";
cin>>grade;

if (grade>= 90)
letter -grade = "A";

what am I missing, and how do I close the statement once it reaches to F
Sep 20 '06 #1
3 1232
Banfa
9,065 Expert Mod 8TB
[code]
if (grade>= 90)
letter_grade = 'A';
[/codeif is a statement NOT a function

What you have here is a complete if statement, it needs no closing, note I have corrected your string constant to a character constant and made your variable name valid.

If you want to execute more than 1 line of code when the condition is true then put in braces and have an if block

Expand|Select|Wrap|Line Numbers
  1. if (grade>= 90)
  2. {
  3.   letter_grade = "A";
  4.   totalA++;
  5. }
  6.  
You did not show code extending to 'F' so it is a little hard to know what you mean however are you talking about if - else if - else

Expand|Select|Wrap|Line Numbers
  1. if (grade>= 90)
  2. {
  3.   letter_grade = 'A';
  4. }
  5. else if (grade>= 80)
  6. {
  7.   letter_grade = 'B';
  8. }
  9. else
  10. {
  11.   letter_grade = 'F';
  12. }
  13.  
Sep 20 '06 #2
QUOTE=Banfa][code]
if (grade>= 90)
letter_grade = 'A';
[/codeif is a statement NOT a function

What you have here is a complete if statement, it needs no closing, note I have corrected your string constant to a character constant and made your variable name valid.

If you want to execute more than 1 line of code when the condition is true then put in braces and have an if block

Expand|Select|Wrap|Line Numbers
  1. if (grade>= 90)
  2. {
  3.   letter_grade = "A";
  4.   totalA++;
  5. }
  6.  
You did not show code extending to 'F' so it is a little hard to know what you mean however are you talking about if - else if - else

Expand|Select|Wrap|Line Numbers
  1. if (grade>= 90)
  2. {
  3.   letter_grade = 'A';
  4. }
  5. else if (grade>= 80)
  6. {
  7.   letter_grade = 'B';
  8. }
  9. else
  10. {
  11.   letter_grade = 'F';
  12. }
  13.  
[/quote]


Thank you for you taking time out to guide me in the right direction. I am using Visual Studio 6.0, and I was unclear to write the statement so that it is recognize, you hit on the nose with the rest of the code you provided. I just do not know what shoud I start with before letter grade or IF .
Sep 20 '06 #3
Banfa
9,065 Expert Mod 8TB
What you had in your original post looks about right to me
Sep 21 '06 #4

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

Similar topics

28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
7
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
17
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
7
by: Rainer Queck | last post by:
Hello NG, I am currently confronted with the task to equip a vs2005 project with context sensitive online help (F1). Reading through the MSDN-Library I found out about the "HelpProvider" class,...
9
needhelp123
by: needhelp123 | last post by:
Can any one send me a quick sort simple logic pogram... its very urgent urgent
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
1
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.