void print_stars(): void option_list): void divisors(int n); int summation(int s); int factorial (int n); int main(void) ( int number, resu char flag printf("Enter an int
void print_stars(): void option_list): void divisors(int n); int summation(int s); int factorial (int n); int main(void) ( int number, resu char flag printf("Enter an int
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...
Related questions
Question

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);

Transcribed Image Text:Question #2:
Study the following C program and answer the below questions
Hint: you might run it in Dev C++ before starting answering the questions!
a) Show a sample output of the program.
b) Extract a function declaration (prototype) for:
1) void functions with void argument
2) void function with a single input argument
3) function with a single input argument and return
4) a recursive function
c) What is the difference between normal functions and recursive functions?
d) How many times are the function print_stars() called in the program? (mention the line number of each
call).
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY