help!!! 
Author Message
 help!!!

I'm suppose to write a program that prompts the user if another run should be
made. If yes, repeat the process... else, quit program. Can anybody tell what
what I'm doing wrong?

Thanks....

#include <stdio.h>
#define MAX 127
int main(void)

{
        int num1 = 0;
        int num2 = 0;
        char yes;

        printf("Enter starting and ending values: \n");
        scanf("%d %d" ,&num1,&num2);
        if (num1<= MAX && num2 <=MAX)
                {
                        printf("dec     hex     char\n");
                        for (num1 = num1; num1 <=num2; num1++)
                        printf("%d      %x      %c\n", num1,num1,num1 );
                }
        else
                printf("Please do not not input a value greater than 127\n");
                        printf("Try another range? (y/n): \n");
                        scanf("%c", &yes);
                        if (yes == 'y'|| yes == 'Y')
                        {
                                printf("%c", yes);
                                printf("Enter starting and ending values:\n");
                        }
                        else
                                printf("Goodbye!");

                        return 0;

Quote:
}

--



Wed, 19 Mar 2003 03:00:00 GMT  
 help!!!

Quote:

> I'm suppose to write a program that prompts the user if another run should be
> made. If yes, repeat the process... else, quit program. Can anybody tell what
> what I'm doing wrong?

> Thanks....

> #include <stdio.h>
> #define MAX 127
> int main(void)

> {
>         int num1 = 0;
>         int num2 = 0;
>         char yes;

>         printf("Enter starting and ending values: \n");
>         scanf("%d %d" ,&num1,&num2);
>         if (num1<= MAX && num2 <=MAX)
>                 {
>                         printf("dec     hex     char\n");
>                         for (num1 = num1; num1 <=num2; num1++)
>                         printf("%d      %x      %c\n", num1,num1,num1 );
>                 }
>         else
>                 printf("Please do not not input a value greater than 127\n");
>                         printf("Try another range? (y/n): \n");
>                         scanf("%c", &yes);
>                         if (yes == 'y'|| yes == 'Y')
>                         {
>                                 printf("%c", yes);
>                                 printf("Enter starting and ending values:\n");
>                         }
>                         else
>                                 printf("Goodbye!");

>                         return 0;
> }
> --


Regardless of your response, you encounter the 'return 0;' statement
and your program terminates.  Try surrounding your body with a do/while
loop which tests the value of 'yes':

  ...
  do {
      printf("Enter starting and ending values: \n");
      scanf("%d %d" ,&num1,&num2);
      ...
      ...
      ...
      printf("Try another range? (y/n): \n");
      scanf("%c", &yes);
  } while( toupper(yes) == 'Y' );

Yours,

Geoff Houck
systems hk

http://www.teleport.com/~hksys
--



Wed, 19 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP HELP HELP HELP HELP HELP!!!

2. HELP HELP HELP HELP HELP

3. HELP ++++++++++++++ HELP +++++++++++ HELP ++++++++++++++ HELP

4. OSP (Operating System Project) HELP HELP HELP HELP (files module)

5. HELP help HELP help

6. help VIRUS help help VIRUS help !

7. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

8. Help Help Help

9. Help ,Help <help , with my project

10. SOMEONE HELP ME, HELP ME, HELP ME PLEASE...

11. HELP HELP HELP ME PLEASE!!

12. HELP HELP HELP!!!

 

 
Powered by phpBB® Forum Software