Click here to Skip to main content
15,441,149 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In the examinations, the DPS and NDPS schools students were allowed to sit on the same desk (Maximum=2) if they had the exact date of birth. As per the condition, there are four students of DPS School whose date of birth matches with the four students of NDPS School

If two students are sitting on the same desk, there is a high chance of copying because the test paper contains objective questions. To check this, you are given a task to determine if there are any students (same desk, with the same date of birth) whose marks match with such students exist other students (subject wise).
o accomplish this, write a program to determine if such students exist or not. If there exist more than 5 cases where the marks of one student match with the marks of another student (same desk), then print a message "COPIED"; otherwise, display a message "FAIR EXAMINATION."

Suggested logic
1.      Think multidimensionality to store the values separately
2.      Iterate through all the elements, and compare elements
3.      Count whenever there exists a matching condition.

In Input, the First 3 rows show DPS marks and student details,
The next 3 rows show NDPS marks and student details:

10 20 13 11
8 15 16 17
9 10 11 12

10 20 23 24
19 13 14 17
20 21 22 23

What I have tried:

this ques has to be done by Multidimensional Array, yes I have tried and having errors in my code
Updated 14-Mar-22 22:13pm
Patrice T 15-Mar-22 3:08am    
You have a secret error in your secret code.

I have tried and having errors in my code

And how do you expect us to fix them without being able to access the code, or have any idea what the errors might be?

Two things:
1) Compiling does not mean your code is right! :laugh:
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.

So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.

Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input   Expected output    Actual output
  1            2                 1
  2            4                 4
  3            6                 9
  4            8                16
Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
private int Double(int value)
   return value * value;

Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!

2) While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

If you want help with a specific problem with your code, you need to show us the relevant code fragments and explain what the problem is: error messages, inputs, output, what it did that you didn't expect, or didn't do that you did. Tell us what you tried to fix it, and what effect that had.

If you want us to write code you can just hand in, you are right out of luck ...
Share this answer
Try with starting some Learn C tutorial or some video tutorial

some tips: use functions and structs with understandable names and install some IDE like Visual Studio..
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900