Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:15:36+00:00 2026-05-31T17:15:36+00:00

the below code is working fine if the user enters the USN number that

  • 0

the below code is working fine if the user enters the USN number that he has already entered.
but again if he enters the same USN number one mare time that is accepted. i tried checking the
USN number using infinite loop (;;), but i don’t know how to exit from the infinite loop.

Is there any solution for it. or please suggest me how to terminate the infinite loop.

void student :: GetData()
 {

  cout<<"Enter the number of students record wolud you like to enter(10 records as MAX): ";

  cin>>MAX;

  cout<<"\n Now enter the "<<MAX<<"students records\n";


  student so[10]; // SO is Student Object

 int i;

    for(i=0;i<MAX;i++)
      {
    cout<<"Enter the Name: ";
    cin>>so[i].name;
    cout<<"\nEnter the USN num.: ";
    cin>>so[i].USN;


     for(int k=1;k<i;k++)
    {
     if (so[i].USN == so[k].USN); // here it finds the if the entered USN number exist or not
        {
            cout<<"The USN number exist try new one: ";
            cin>>so[i].USN;    
        } // But after this statement if he enter the same exist USN number is accepting

          //I need you guys to help me out at this point
    }

    cout<<"\n Enter the Three Marks: ";

      for(int j=0;j<3;j++)
    {
      cin>>so[i].marks[j];
    }
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:15:38+00:00Added an answer on May 31, 2026 at 5:15 pm

    Do this:

    if (so[i].USN == so[k].USN) {
       ...
    }
    else break;
    

    And you had a syntax problem there

    if (so[i].USN == so[k].USN); <-- the ; is wrong here because it would end the if right away
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code below is working well as long as I have class ClassSameAssembly in same
The code below is working, but with a problem I do not understand. When
This line of code is working fine for Firefox $(#<%=txt1.ClientID%>).text() but not for IE8
Code is working fine but i want to add my own location . for
I have below code in vb.net for validating alphanumeric characters, It is working fine
I've got an iframe application that's working fine and rendering fbml in facebook. But
The below code is working great for handling errors for text fields in my
The code below working for only first div. I can't display other divs when
The code below is working nearly flawlessly, however my value for page title on
I am using the below code to block the taskbar which is working perfectly.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.