e) What does each function do? Hint: Write a simple description for each of the user-defined functions. vold print_stars(): void option_list() vold divisors(int n) Example: This function takes one argument of type int and prints its divisors on the screen, including, 1 and itself. Int summation(Int s) int factorial (int n)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
1include<stdio.h>
void print_stars();
* void option_list();
void divisors(int n);
int summation(int s);
int factorial (int n);
int main(void) (
int number, result, op;
char flag:
11
printf("Enter an integer number > ");
scanf( "%d" , &number );
dol
option_list();
scanf("%d", &op);
10
11
switch(op) (
1A
case 1:
divisors(number):
break;
19
case 2:
result = summation(number);
printf("Summation - %d\n" , result);
YY
break;
YO
case 3:
result = factorial(number)
printf("Factorial - %d\n" , result);
break;
default:
printf("\NERROR: %d is unrecognized option!!! \n", op);
;
TY
TA
print_stars();
printf("Do you want to check another function? (Y/N)> ");
scanf(" %c" , &flag):
) while (flag == "Y || flag == 'y);
ro
return 0;
t. void option_list(){
print_stars():
printf("1: Find the divisors \n"):
printf("2: Compute the summuation\n");
printf("3: Compute the factorial n");
print_stars();
printf("Please enter your choice: ");
EA void print_stars(){
int i;
for(i- 1;i< 25 ; i++)
printf("");
or
printf("\n");
00
01 void divisors(int n) {
ov
int i;
printf("Divisors of %d are\n",n):
for(i=1;icen;i++)
if(n%i==0)
printf(" %d",);
1.
printf("\n");
10 int factorial (int n)
11 int i, fact = 1;
for (i-2;ice n; i++)
fact *=i;
return fact;
1A
19
Y int summation(int s)
VY if (s == 0)
vr
return O;
YE
else
YO
return s+ summation(s-1);
Transcribed Image Text:1include<stdio.h> void print_stars(); * void option_list(); void divisors(int n); int summation(int s); int factorial (int n); int main(void) ( int number, result, op; char flag: 11 printf("Enter an integer number > "); scanf( "%d" , &number ); dol option_list(); scanf("%d", &op); 10 11 switch(op) ( 1A case 1: divisors(number): break; 19 case 2: result = summation(number); printf("Summation - %d\n" , result); YY break; YO case 3: result = factorial(number) printf("Factorial - %d\n" , result); break; default: printf("\NERROR: %d is unrecognized option!!! \n", op); ; TY TA print_stars(); printf("Do you want to check another function? (Y/N)> "); scanf(" %c" , &flag): ) while (flag == "Y || flag == 'y); ro return 0; t. void option_list(){ print_stars(): printf("1: Find the divisors \n"): printf("2: Compute the summuation\n"); printf("3: Compute the factorial n"); print_stars(); printf("Please enter your choice: "); EA void print_stars(){ int i; for(i- 1;i< 25 ; i++) printf(""); or printf("\n"); 00 01 void divisors(int n) { ov int i; printf("Divisors of %d are\n",n): for(i=1;icen;i++) if(n%i==0) printf(" %d",); 1. printf("\n"); 10 int factorial (int n) 11 int i, fact = 1; for (i-2;ice n; i++) fact *=i; return fact; 1A 19 Y int summation(int s) VY if (s == 0) vr return O; YE else YO return s+ summation(s-1);
e) What does each function do?
Hint: Write a simple description for each of the user-defined functions.
vold print_stars():
void option_list()
void divisors(int n)
Example:
This function takes one argument of type int and prints its divisors on the screen, including, 1 and itself.
int summation(int s)
int factorial (int n)
End of Homework ====
Page 8 of 8
Transcribed Image Text:e) What does each function do? Hint: Write a simple description for each of the user-defined functions. vold print_stars(): void option_list() void divisors(int n) Example: This function takes one argument of type int and prints its divisors on the screen, including, 1 and itself. int summation(int s) int factorial (int n) End of Homework ==== Page 8 of 8
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY