1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
int main(void)
{
int numm;
char response = 'Y';
char responsee = 'Y';
clrscr();
printf("\n MAIN MENU");
printf("\n 1. Random Numbers");
printf("\n 2. Count Character");
printf("\n 3. Exit");
printf("\n Enter your choice: ");
scanf("%d",&numm);
if(numm==1)
{
srand (time(NULL));
int num,num1,num2,num3,answer,ans;
clrscr();
while (response == 'y' || response == 'Y'){
clrscr();
printf("Input a Integer: ");
scanf("%d",&num);
num1 = rand() % num + 1;
int temp1 = num - num1;
num2 = rand() % temp1 + 1;
num3 = num - (num1 + num2);
answer=num1+num2+num3;
printf("num1 = %d\n",num1);
printf("num2 = %d\n",num2);
printf("num3 = %d\n",num3);
printf("The Total is: %d\n",answer);
printf("DO YOU WANT TO TRY AGAIN? Y/N: ");
scanf("%s",&response);
}
}
else if(numm==2)
{
int strlength;
int ans;
char *str;
clrscr();
while (responsee == 'y' || responsee == 'Y'){
clrscr();
printf("\nEnter the string: ");scanf("%d",&strlength);
gets(str);
strlength=strlen(str);
printf("\nThe length of the string is %d.\n",strlength);
printf("\nDO YOU WANT TO TRY AGAIN? Y/N: ");
scanf("%s",&responsee);
}
}
else exit(0);
{
getch();
//return 0;
}}
|