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 66
|
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define p printf
#define s scanf
void main()
{
int z,a,b,c;
int function_count();
int function_random();
int function_exit();
//clrscr();
p("*************");
p("\n\nMAIN MENU");
p("*************");
p("\n\nEnter Compilation:\t");
p("a - Count The Characters");
p("b - Random Numbers");
p("c - Exit");
scanf("%d", &z);
if(z=='a')
{
function_count();
}
else if(z=='b')
{
function_random();
}
else if(z=='c')
{
function_exit();
}
function_count();
{
int strlength;
char *str;
clrscr();
printf("\nEnter the string: ");
gets(str);
strlength=strlen(str);
printf("\nThe length of the string is %d.",strlength);
getch();
}
function_random();
{
srand (time(NULL));
int num,num1,num2,num3,answer;
clrscr();
printf("Input a interger: ");
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",answer);
getch();
}
}
| |