473,396 Members | 2,076 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,396 software developers and data experts.

Using arrays in C.

Hi,

I'm pretty new to c-programming and am taking a course in it. I'm
trying to write a menu program using functions and a two-dimensional
array. The program consists of entering 4 test grades for 10 students.
The array is initialized with -1 in the beginning - this is because if
a student did not take a test yet I want to be able to sort and find
this out. There is a menu option to enter grades which calls a
function in order to enter the student - 1-10, the test number 1-4 and
the grade. The problem I am running into is I want to display a
message to prompt the user that there is a grade already present if
the grade was entered before - and allow the user to replace the grade
or leave it as is. here is that part of the code:

int enterInfo (int, int, double)

{ while (1)
{
int Stud_Num,
Exam_Num,
Grade_Num,
response,
response1;

cout << "Please Enter a Student Number > ";
cin >> Stud_Num;

if ((Stud_Num <1) || (Stud_Num >10))

{
cout << "\n\nInvalid entry, Please try again! \n";
return Stud_Num;
}
else
cout << "\nPlease Enter an Exam Number > ";
cin >> Exam_Num;

if ((Exam_Num <1) || (Exam_Num >4))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Exam_Num;
}
else
cout << "\nPlease Enter a Grade > ";
cin >> Grade_Num;

//if ((Grade_Num >=0) && (Grade_Num <=100))
//{
//cout << "\nStudent already has a grade entered for this exam. \n";
//cout << "\nDo you want to replace the grade? Enter 1 for Yes or 0
for no: \n ";
//cin >> response;
// if (response == 1)
// return Grade_Num;
// }
// else
// return response;
if ((Grade_Num <0) || (Grade_Num >100))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Grade_Num;
}

else
cout << "\nDo you want to enter another grade?: \n";
cout << "\nEnter 1 for Yes or 0 for No > ";
cin >> response1;
if (response1 != 0)
int main();
else
return response1;
}
}
Can anyone please explain to me how to include this in my program or
what I'm doing wrong?

BTW - A working model is located at this website:
as.sunyorange.edu/~insttg/
55171EF C Programming
Grades Program With Multiple Function Calls

There is no source code but you're able to run the completed program
and understand what I'm trying to do. Thanks...
TonyT.
Nov 13 '05 #1
2 4326
Tonytt wrote:
Hi,

I'm pretty new to c-programming and am taking a course in it.
<snip>
cout << "Please Enter a Student Number > ";


I think you mean you're pretty new to C++ programming. Try comp.lang.c++ for
help with C++ code.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #2
In article <98**************************@posting.google.com >,
Tonytt <to*****@msn.com> wrote:
I'm pretty new to c-programming and am taking a course in it. [snip] cout << "Please Enter a Student Number > ";
cin >> Stud_Num; [snip]BTW - A working model is located at this website:
as.sunyorange.edu/~insttg/
55171EF C Programming


That's rather curious. The course is called "C Programming" but
your program is in C++. What's going on in your class?

--
Rouben Rostamian
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the...
10
by: Chamomile | last post by:
I have been happily using array members as id's in my html code (either hand coded or generated by server-side script-php ) for some time. eg < input type='text' id='arrayItem' >< input...
1
by: Brian McGuinness | last post by:
I have a question about using the STL transform algorithm in a function. What I want to do is define a group of array classes to represent APL-style arrays (arrays in which the number of...
138
by: ambika | last post by:
Hello, Am not very good with pointers in C,but I have a small doubt about the way these pointers work.. We all know that in an array say x,x is gonna point to the first element in that...
2
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my...
39
by: Mark Odell | last post by:
I've always declared variables used as indexes into arrays to be of type 'size_t'. I have had it brought to my attention, recently, that size_t is used to indicate "a count of bytes" and that using...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
4
by: mantrid | last post by:
Im using arrays generated from my records displayed in a table on my site to update the corresponding records in a mysql database ie on the web page col1 col2 col3 1 2 2 1 ...
2
by: arnuld | last post by:
i do not have any problem here. i solved the problem but i wanted to know the views of you. please look at it from a newbie's perspective: problem: define a table with names of months of the...
16
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.