Professional Documents
Culture Documents
/****************************************************************
******************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
double diff;
time_t start,end;
for(m_value=0;m_value<5;m_value++)
for(n_value=0;n_value<10;n_value++)
call=0;
printf("**********END***********");
break;
1
acker_value = ackermann ( m_value, n_value);
printf("Time:%.2f\n",diff);
getchar();
return 0;
call++;
if ( m == 0 ){
2
1.1.2 Print Screen
3
1.2 Ackermann Value Table
m n Ackermann Number of Time Taken
value Function to Run the
Called Function
0 0 1 1 0.00
0 1 2 1 0.00
0 2 3 1 0.00
0 3 4 1 0.00
0 4 5 1 0.00
0 5 6 1 0.00
0 6 7 1 0.00
0 7 8 1 0.00
0 8 9 1 0.00
0 9 10 1 0.00
1 0 2 2 0.00
1 1 3 4 0.00
1 2 4 6 0.00
1 3 5 8 0.00
1 4 6 10 0.00
1 5 7 12 0.00
1 6 8 14 0.00
1 7 9 16 0.00
1 8 10 18 0.00
1 9 11 20 0.00
2 0 3 5 0.00
2 1 5 14 0.00
2 2 7 27 0.00
2 3 9 44 0.00
4
2 4 11 65 0.00
2 5 13 90 0.00
2 6 15 119 0.00
2 7 17 152 0.00
2 8 19 189 0.00
2 9 21 230 0.00
3 0 5 15 0.00
3 1 13 106 0.00
3 2 29 541 0.00
3 3 61 2432 0.00
4 0 13 107 0.00
1.3. Based on the Ackermann value table, when the m = 3 and n= 9, the
Ackermann values start to have a drastic difference. It is because when the m=3,
the value of the Ackermann is equal to 5+8*(2^n-1) which is power 2 to the
value of n. Therefore, the Ackermann values are m = 3 series will increase
dramatically as ‘n’ increase. Therefore, when m = 3 and n=9, Ackermann values
which has been increased 2048 consider to have a drastic difference.
5
PART 2
2.1 C Programming Code
/****************************
SID : 09ACB02875
Practical : P9;
******************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <ctype.h>
//variable
6
int main()
printf("\t\t*********************************************\n");
printf("\t\t*********************************************\n");
printf("\t\t*********************************************\n");
system("cls");
return 0;
void EnterName()
7
char *StuName[10]; //max 10 student in program
do{
fflush(stdin);
for (i=0;i<size;i++)
printf("------------------------------\n");
/*if no name list then allow user input, else use the name list */
if (document == NULL){
for(i=0;i<size;i++){
scanf("%[^\n]s",&name[i]);
fflush(stdin);
StuName[i]=name[i];
8
}
}else{
for(i=0;i<size;i++){
fscanf(document," %[^\n]s",name[i]);
StuName[i]=name[i];
fclose(document);
for(i=0;i<size;i++){
SortNameInAscending(StuName,size);
PrintName(StuName,size);
SearchName(StuName,size);
int j ;
char *temp;
9
temp = StuName[i];
StuName[i] = StuName[j];
StuName[j] = temp;
printf("----------------------------------\n");
char SName[30];
int search[10];
scanf("%[^\n]s",&SName);
fflush(stdin);
for(i=0;SName[i];i++)
SName[i] = tolower(SName[i]);
10
}
for(i=0;i<size;i++){
search[i] = strcmp(StuName[i],SName);
if (search[i]==0){
break;
if (search[i] == 0){
}else{
return -1;
11
Allow User Enter Student Number
12
Sort the name and print in alphabetical order
13
14