undefinedundefined

hi every body. well i am a new member and i hope that i am doing things the right way . well my problem is that i am a first year students and obvoisly i am studying c++. but i got an assignmet to do. i wrote the code but i just dont know where the problem is. please help me out. i have tried to do the programme in different ways but still it isnot working properly. can i mail you the c++ code and please can you clear me about what the problem is thank you very much for kind coorporation. by the way your web site is an extremely good one and very objectuve and helpful. good luk and keep it up

Attachments
// programming assignment

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include <process.h>

struct students{
char name[25];
char address[50];
int num_modules;
int module[4];
int module_marks[4];
};

/*void display (struct students x )
{
  int i;
   for (i=0;  i<=2;  i++)
    {
      cout<<"The name of the student is: "<<x.name;
      cout<<"\n\n";

      cout<<" the student's address is : "<<x.address;
      cout<<"\n\n";

      cout<<" The number of modules taken is : "<<x.num_modules;
      cout<<"\n\n";
      switch (x.num_modules)
      {
	  case 1:
	 {
	  cout<<" The module number is: "<<x.module[0];
	  cout<<"\n\n";

	  cout<<"marks obtained in that module is: "<<x.module_marks[0];
	   break;
	   }
	case 2:
	 {
	     for(i=0; i<=1; i++)
	     {
	      cout<<" The module number is: "<<x.module[i];
	       cout<<"\n\n";

	      cout<<" The marks for that module is: "<<x.module_marks[i];
	      cout<<"\n\n";
	      }
	     break;
	   }
	//  clrscr();
	  case 3:
	  {
	   for(i=0; i<=2; i++)
	     {
	      cout<<"The module number is: "<<x.module[i];
	      cout<<"\n\n";
	       cout<<" The marks for that module is: "<<x.module_marks[i];
	      cout<<"\n\n";
	      }
	    break;
	    }
//clrscr();

	    case 4:
	    {
	       for(i=0; i<=3; i++)
	       {
		 cout<<"The module number is: "<<x.module[i];
		cout<<"\n\n";

		 cout<<" The marks for that module is: "<<x.module_marks[i] ;
		cout<<"\n\n";
	       }
	      break;
	      }
	     // clrscr();

      }

     break;

    }
}
*/

void main ()
{
students mgt_students[3];
int i;
clrscr();
 for (i=0;  i<=2;  i++)
 {
  clrscr();
  cout<<"\n\n";
 // fflush(stdout);
  cout<<" Please enter the name of the student: ";
  cin.getline (mgt_students[i].name,25);
  cout<<"\n\n";
 // fflush(stdin);

  cout<<" Please enter the student's address: ";
  cin.getline (mgt_students[i].address,50);
  cout<<"\n\n";
	fflush(stdin);
  cout<<" Please enter the number of modules taken: ";
  cin>>mgt_students[i].num_modules;

		switch (mgt_students[i].num_modules)
		{
		  case 1:
			{
				  cout<<" Please enter the modules number: ";
					cin>>mgt_students[i].module[i];
					cout<<"\n\n";

				 cout<<"Please enter the marks obtained in that module: ";
				  cin>>mgt_students[i].module_marks[i];
				  break;
					  //clrscr();
			}

		  case 2:
			{
			  for(i=0; i<=1; i++)
			  {
				  cout<<" Please enter the module number: ";
					cin>>mgt_students[i].module[i];
					cout<<"\n\n";

				  cout<<" Please enter the marks for that module: " ;
					cin>>mgt_students[i].module_marks[i];
					cout<<"\n\n";
			  }
			  break;
			 }
			 // clrscr();
		 case 3:
		  {
			  for(i=0; i<=2; i++)
				{
				  cout<<" Please enter the module number: ";
				  cin>>mgt_students[i].module[i];
				  cout<<"\n\n";

					cout<<" Please enter the marks for that module: " ;
					cin>>mgt_students[i].module_marks[i];
				  cout<<"\n\n";
				}
			 break;
		  }
	 //clrscr();

		  case 4:
		  {
			 for(i=0; i<=3; i++)
			 {
				  cout<<" Please enter the module number: ";
				 cin>>mgt_students[i].module[i];
				cout<<"\n\n";

				 cout<<" Please enter the marks for that module: " ;
			  cin>>mgt_students[i].module_marks[i];
				cout<<"\n\n";
			 }
			break;
		  }
		  // clrscr();

	  }
  }
//for(i=0;i<=2;i++)
 // {
 // display (mgt_students[i]);
 // }

 for(i=0; i<=2; i++)
 {
  cout<<" The students name is: "<<mgt_students[i].name;
  cout<<"\n\n";

  cout<<"Students address is : "<<mgt_students[i].address;
  cout<<"\n\n";

  cout<<" the number of modules taken is : "<<mgt_students[i].num_modules;
  cout<<"\n\n";
	  switch (mgt_students[i].num_modules)
	  {
		  case 1:
		  cout<<" the module number is: "<<mgt_students[i].module[i];
		  cout<<"\n\n";

		  cout<<" tHE CORRESPONDING MARK IS: "<<mgt_students[i].module_marks[i];
		  break;

		  case 2:
			{
				for (i=0; i<=1; i++)
				{
				  cout<<"the module number is: "<<mgt_students[i].module[i];
				  cout<<"\n\n";

				  cout<<" The corressponding marl is: "<<mgt_students[i].module_marks[i];
				  cout<<"\n\n";
				  }
				  break;
			}

		 case 3:
			{
				for (i=0; i<=2; i++)
				{
				  cout<<"the module number is: "<<mgt_students[i].module[i];
				  cout<<"\n\n";

				  cout<<" The corressponding marl is: "<<mgt_students[i].module_marks[i];
				  cout<<"\n\n";
				  }
				  break;
			}


			case 4:
			{
				for (i=0; i<=3; i++)
				{
				  cout<<"the module number is: "<<mgt_students[i].module[i];
				  cout<<"\n\n";

				  cout<<" The corressponding marl is: "<<mgt_students[i].module_marks[i];
				  cout<<"\n\n";
				  }
				  break;
			}

	  }
getch ();
}

i already saw ur program.... u miss a curly braces after ur getch();.....
i solve 1 problem but wat is this "clrscr();" ??? it is clear screen ??? if it is ..... it should be system("cls");

>if it is ..... it should be system("cls");
No it shouldn't. Then you would add two problems to already nonportable code. If a screen clear is warranted, then it should be changed to something that the implementation supports, preferrably by doing something like this to make porting easier in the future:

void clear_screen()
{
  // Some nonportable solution similar to clrscr()
}

That way you can call clear_screen rather than the nonportable function and any changes are localized to that function.

Hi,
I do not understand, why are you using similar set of code time and again..???
Moreover, you have mixed the features of C & C++. Try making it an object oriented one if you are creating a .cpp file. Other problems have already been solved in previous replies.

- Anurag.

This article has been dead for over six months. Start a new discussion instead.