|
I'm juz a newbie in C++... there are still many question mark in my head... gosh!!!! Nid help from u guys....
Recently, i gt some kind of question sounds calculates the average score for students in a particular class based on user input. The program will require input results of 10 students..... The question want me to declare and initialize a symbolic constant for 10 student.... How can i do it????... help pls.... TTv |
|
|
|
|
|
|
|
what means symbolic constant?
the question sound is street to the point but symbolic constant make me sense.never heard this term b4. |
|
|
|
|
|
|
|
Actually i'm still wondering what actually is the symbolic constant..... gosh!!! Thats why i;m stuck.... argh... forget it... TTv |
|
|
|
|
|
|
|
Reply 3# joyeric
A symbolic constant is a constant that is represented by a name, just as a variable is represented. Unlike a variable, however, after a constant is initialized, its value can't be changed. There are two ways to declare a symbolic constant in C++. The old, traditional,and now obsolete way is with a preprocessor directive, #define. DefiningConstants with #define To define a constant the traditional way, you would enterthis:#define studentsPerClass 15
|
|
|
|
|
|
|
|
Reply 3# joyeric
here my coding.
- #include <iostream>
- #define paria 10
- using namespace std;
- void paria2 ( double pariah) { cout<<"\nAverage student mark is : "<<pariah/paria<<endl;}
- void main() {
- double marks, koling=0;
- for (int a=0;a<paria;a++)
- {
- cout<<"Key in student "<<a+1<<" marks : ";
- cin>>marks;
- koling+=marks;
- }
-
- paria2 ( koling );
- }
Copy the Code |
|
|
|
|
|
|
|
Reply 5# otai_g
apa ke paria pulak perginye? |
|
|
|
|
|
|
|
Reply 6# abundek
heh motif up thread lama?
btw time buat coding tu kepala aku terpikir yg perangai tt mcm yg tersebut, so terus aku guna variable tuh.. |
|
|
|
|
|
|
|
Reply 7# otai_g
kelemahan aku kot, suka tengok tajuk topik "please help please!" |
|
|
|
|
|
|
| |
|