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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:33:27+00:00 2026-05-30T18:33:27+00:00

This is a self-help program I made for useful break activities. At the end

  • 0

This is a self-help program I made for useful break activities. At the end of it need to type a number, then press “enter” to restart. I’d rather have to only type anything, or any number.

#include <stdio.h>
#include <stdlib.h>

main()
{
  int i;

  srand((unsigned)time(NULL));

  i = rand();

  int k;
  k = (int)i%22;
  printf("\n\n");

   switch(k){


            case 0: printf("%\t Weather"); printf(" weather"); break;                        
            case 1: printf("\t Hand exercises ok"); break;

            case 2: printf("\t BR break"); break;

            // etc etc            
            case 15: printf("\t ~~ DOODLE ON PAPER ## "); break;
            case 16: printf("\t Practice Mental Math "); break;
            case 17: printf(" \tgo to SNOPES.com\t"); break;

            case 18: printf("\t Browse JAVA API"); break;
            case 19: printf("\t Left handed writing"); break;
            case 20: printf("\tGo outside OUTSIDE\t"); break;
            case 21: printf("\tCall M&K\t"); break;
            case 22: printf("TRASH CAN BBALL\t"); break;


            }

            printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

        long g;

        scanf("%d", &g);

        if(g >0){
                 system("cls");
                 main();
                 }


     system("pause");
}

I use this as a simple Windows App. If there are other issues/problems I’m totally open to criticism as I’m still new to C. I appreciate any tips or advice.

  • 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-30T18:33:28+00:00Added an answer on May 30, 2026 at 6:33 pm

    If you have access to the conio library, you can use kbhit() to catch a keypress:

    #include <conio.h>
    
    int main(void) {
      while (1) {
        /* ... */
    
        if(kbhit())
        {
           break;
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with some programming logic... I need to loop this method to
I hope you will help me understand this Copy Constructor I took more then
I wrote this simple python program to help me with a bug in another
I'm currently displaying a UIViewController like this: [[self navigationController] presentModalViewController:modalViewController animated:YES]; and hiding it
This code: (self is a subclass of NSView) rotate = [CABasicAnimation animationWithKeyPath:@transform.rotation.z]; rotate.duration =
Something like this: if self.__class__ == User: logging.debug(%s non_pks were found % (str(len(non_pks))) )
This is a self-explanatory question: Why does this thing bubble into my try catch's
This question is self explanatory if you know how to use JMockit: How do
I have a definition like this def bar(self, foo=None, bar=None, baz=None): pass I want
It seems that often __init__ methods are similar to this: def __init__(self, ivar1, ivar2,

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.