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 414561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:17:41+00:00 2026-05-12T18:17:41+00:00

void distinct (void) { char sent; int n1, n2, n3, n4, n5, n6, n7;

  • 0
void distinct (void) {
 char sent;
 int n1, n2, n3, n4, n5, n6, n7;
 FILE *fp2 = fopen ("distinct.txt", "w");

 while (sent != 'n') {
  for (n1=2;n1<=9;n1++) {
   for (n2=2;n2<=9;n2++) {
    if (n2 != n1) {
     for (n3=2;n3<=9;n3++) {
      if (n3 != n2 && n3 != n1) {
       for (n4=2;n4<=9;n4++) {
        if (n4 != n3 && n4 != n2 && n4 != n1) {
         for (n5=2;n5<=9;n5++) {
          if (n5 != n4 && n5 != n3 && n5 != n2 && n5 != n1) {
           for (n6=2;n6<=9;n6++) {
            if (n6 != n5 && n6 != n4 && n6 != n3 && n6 != n2 && n6 != n1) {
             for (n7=2;n7<=9;n7++) {
              if (n7 != n6 && n7 != n5 && /* you get the idea */ && n7 != n1) {
               fprintf (fp2, "%d", n1);
               fprintf (fp2, "%d", n2);
               fprintf (fp2, "%d", n3);
               fprintf (fp2, "%d", n4);
               fprintf (fp2, "%d", n5);
               fprintf (fp2, "%d", n6);
               fprintf (fp2, "%d\n", n7);
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  }
  printf ("Press any key to continue or 'n' to stop writing the file\n");
  scanf ("%c", &sent);
 }
 fclose (fp2);
}

I want the loop to pause whenever the first digit changes to ask whether to continue or stop.

2xxxxxx
2xxxxxx
2xxxxxx
Press any key to continue or 'n' to stop writing the file
    // continues if 'y' is entered //
3xxxxxx
3xxxxxx
3xxxxxx
Press any key to continue or 'n' to stop writing the file
    // stops when 'n' is entered //

The program I wrote doesn’t work as I wish…T___T

  • 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-12T18:17:41+00:00Added an answer on May 12, 2026 at 6:17 pm

    I think in terms of readability, you’re better putting it at the top of the relevant loop. Get rid of the outer while altogether and change:

    char sent;
    : :
    for (n1=2;n1<=9;n1++) {
        for (n2=2;n2<=9;n2++) {
    

    into:

    char sent[100];
    : :
    for (n1=2;n1<=9;n1++) {
        if (n1 > 2) {
            printf("press any key to continue or 'n' to stop writing the file\n");
            scanf("%s",sent);
            if (*sent == 'n') break;
        }
        for (n2=2;n2<=9;n2++) {
    

    The change of sent from a character to a string is so you don’t need to worry about getting linefeeds as characters (if you type yENTER, you’ll get the next two sections since y is one character and ENTER is another – even worse if you enter yesENTER). The use of a fixed size string and scanf() is dangerous however and shouldn’t be used in production code. I include it here only yo make your life a little easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 250k
  • Answers 250k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer it sounds like your web application has the older code… May 13, 2026 at 9:16 am
  • Editorial Team
    Editorial Team added an answer Spring exception resolver not rendering exception view in tomcat due… May 13, 2026 at 9:16 am
  • Editorial Team
    Editorial Team added an answer The solution I came up with: Initially I looked at… May 13, 2026 at 9:16 am

Related Questions

Edit: The reason queue is 2d is because I need a pointer of Command
The task I was trying to accomplish was that given an input pattern, e.g.
class Program { static void Main(string[] args) { List<Book> books = new List<Book> {
Good Morning! Given: public class FooClass { public void FooMethod() { using (var myEntity

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.