Study the following C program and answer the below questions Hint: you might run it in Dev C++ before starting answering the questions! Show a sample output of the program.                                   Extract a function declaration (prototype) for: void functions with void argument ………………………………………………………………………………………………………………… void function with a single input argument ………………………………………………………………………………………………………………… function with a single input argument and return ………………………………………………………………………………………………………………… a recursive function …………………………………………………………………………………………………………………   What is the difference between normal functions and recursive functions?       How many times are the function print_stars() called in the program? (mention the line number of each call).           #include 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;                                 printf("Enter an integer number > ");                 scanf( "%d" , &number );                                 do{                                 option_list();                                 scanf("%d" , &op);                                 switch(op)             {                                                 case 1:                                                                 divisors(number);                                                                 break;                                                 case 2:                                                                 result = summation(number) ;                                                                 printf("Summation = %d\n" , result);                                                                 break;                                                 case 3:                                                                 result = factorial(number) ;                                                                 printf("Factorial = %d\n" , result);                                                                 break;                                                 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');                                 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: "); } void print_stars(){                 int i;                 for(i = 1 ; i <= 25 ; i++)                                 printf("*");                                 printf("\n"); }     void divisors(int n)  {                 int i;                 printf("Divisors of %d are\n",n);                 for(i=1;i<=n;i++)                                 if(n%i==0)                                                 printf(" %d",i);                   printf("\n"); } int factorial (int n){ int i , fact = 1 ;                 for (i = 2 ; i <= n ; i++)                                 fact *= i;                 return fact; } int summation(int s){ if (s == 0)              return 0;                 else                                 return  s + summation(s-1); }     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.   int summation(int s)           int factorial (int n)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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!

  1. Show a sample output of the program.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Extract a function declaration (prototype) for:
    • void functions with void argument

…………………………………………………………………………………………………………………

  • void function with a single input argument

…………………………………………………………………………………………………………………

  • function with a single input argument and return

…………………………………………………………………………………………………………………

  • a recursive function

…………………………………………………………………………………………………………………

 

  1. What is the difference between normal functions and recursive functions?

 

 

 

  1. How many times are the function print_stars() called in the program? (mention the line number of each call).

 

 

 

 

 

#include<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;

               

                printf("Enter an integer number > ");

                scanf( "%d" , &number );

               

                do{

                                option_list();

                                scanf("%d" , &op);

                                switch(op)             {

                                                case 1:

                                                                divisors(number);

                                                                break;

                                                case 2:

                                                                result = summation(number) ;

                                                                printf("Summation = %d\n" , result);

                                                                break;

                                                case 3:

                                                                result = factorial(number) ;

                                                                printf("Factorial = %d\n" , result);

                                                                break;

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

               

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

}

void print_stars(){

                int i;

                for(i = 1 ; i <= 25 ; i++)

                                printf("*");

               

                printf("\n");

}

 

 

void divisors(int n)  {

                int i;

                printf("Divisors of %d are\n",n);

                for(i=1;i<=n;i++)

                                if(n%i==0)

                                                printf(" %d",i);

 

                printf("\n");

}

int factorial (int n){

int i , fact = 1 ;

                for (i = 2 ; i <= n ; i++)

                                fact *= i;

                return fact;

}

int summation(int s){

if (s == 0)

             return 0;

                else

                                return  s + summation(s-1);

}

 

 

  1. 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.

 

int summation(int s)

 

 

 

 

 

int factorial (int n)

 

 

 

 

 

 

 

 

 



Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education