i'm writing a program to capture marks and names of 15 students and then i'll be using a function to display whether those students have failed,supplement or passed. but the problem is i'm using strings to capture those names and i'm using arrays to capture those names and the marks.i'm really confused right now. i've tried everything i can think of. this is what i did below and any suggestions are welcome


using namespace std;

void getInput(char[] ,int&);
void displayResults(char[],int&);

int main()
   int x;

	int MarkP ;

	char NameP[15];
	for(x=1;x<=15; x++)

	return 0;
 void getInput(char NameP[],int &MarkP)

           cout<<"Enter the Name of the student\n";



void displayResults(char NameP[],int &MarkP)

	  cout<<"you failed the course and come next year to repeat\n";

	  if(MarkP>=40 && MarkP<=49)

	    cout<<"You may write the supplementary examination\n";

	  if(MarkP>=50 && MarkP<=74)

		  cout<<"Congratulations!!You passed the examination\n";

	  if(MarkP>=75 && MarkP<=100)

		cout<<"You passes with a distinction\n";

Member Avatar for iamthwee

What exactly are you stuck on?
Are you allowed to std::strings instead of c-style char arrays?

1) Welcome to DaniWeb! Please use code tags for future posts with code or indentation you wish to preserve.

2) Please describe what problem you are experiencing. Does the code you post not compile? Does it compile but not run? Does it run but give erroneous output? Do you get error messages or warnings (If so please copy and paste the first couple messages into the post.)? Do you not understand a concept involving C++ or the underlying algorithm?

Quickly scanning your posted code I don't see a glaring error, but I'm not sure what your problem is for sure. I suspect you may be suffering from the magic number blues, but I can't be sure.

3) A string is, at minimum, a null terminted char array. That means if you have a char array without a null char then you don't have a string. Some strings, like STL strings or APStrings or TStrings or CStrings have other very useful features besides just the null termination but they all have, or are, null terminated char arrays. The type of string you use in your post is the bare C style string, otherwise known as a simple null terminated char array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.