e) What does each function do? Hint: Write a simple description for each of the user-defined functions. void 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.

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
e) What does each function do?
Hint: Write a simple description for each of the user-defined functions.
void 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.
summation(int s)
int factorial (int n)
Transcribed Image Text:e) What does each function do? Hint: Write a simple description for each of the user-defined functions. void 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. summation(int s) int factorial (int n)
#include<stdio.h>
Y 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 );
ir
dol
10
option_list();
scanf("%d" , &op);
switch(op) {
case 1:
19
divisors(number);
Y.
break;
case 2:
YY
result = summation(number);
printf("Summation = %d\n", result);
break;
YO
case 3:
result = factorial(number):
printf("Factorial = %d\n", result);
break;
YY
YA
default:
printf("\NERROR: %d is unrecognized option!!! \n", op);
print_stars();
printf("Do you want to check another function? (Y/N)> "):
scanf(" %c" , &flag);
} while (flag == "Y" || flag == 'y');
rv
return 0;
. 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("");
01
or
or
printf("\n");
00
01 void divisors(int n) {
int i;
printf("Divisors of %d are\n",n);
for(i=1;ic=n;i++)
if(n%i=0)
printf(" %d",i);
09
1.
printf("\n");
10 lint factorial (int n){
11 int i, fact = 1;
for (i = 2; i<= n; i++)
fact * i;
14
return fact;
VI int summation(int s){
if (s == 0)
VY
return 0;
else
YO
return s+ summation(s-1);
Transcribed Image Text:#include<stdio.h> Y 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 ); ir dol 10 option_list(); scanf("%d" , &op); switch(op) { case 1: 19 divisors(number); Y. break; case 2: YY result = summation(number); printf("Summation = %d\n", result); break; YO case 3: result = factorial(number): printf("Factorial = %d\n", result); break; YY YA default: printf("\NERROR: %d is unrecognized option!!! \n", op); print_stars(); printf("Do you want to check another function? (Y/N)> "): scanf(" %c" , &flag); } while (flag == "Y" || flag == 'y'); rv return 0; . 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(""); 01 or or printf("\n"); 00 01 void divisors(int n) { int i; printf("Divisors of %d are\n",n); for(i=1;ic=n;i++) if(n%i=0) printf(" %d",i); 09 1. printf("\n"); 10 lint factorial (int n){ 11 int i, fact = 1; for (i = 2; i<= n; i++) fact * i; 14 return fact; VI int summation(int s){ if (s == 0) VY return 0; else YO return s+ summation(s-1);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 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