SlideShare a Scribd company logo
1 of 1
Download to read offline
Problem 4 (10 pts): Write a complete C program and create a user defined function with the
following prototype: int sum_of_digits(int); The function should return the sum of all digits in
the given number. For example, if an integer is 932 , the sum of all its digits is 14 . Hint: Use the
% operator to extract digits and use the / operator to remove the extracted digit. For instance,
932%10=2 and 932/10=93. In the main function scan an integer number from the user and print
the result of sum_of_digits function.

More Related Content

More from aludin007

Programming II hiding, and .pdf
 Programming II hiding, and .pdf Programming II hiding, and .pdf
Programming II hiding, and .pdf
aludin007
 
Process design focuses on.pdf
 Process design focuses on.pdf Process design focuses on.pdf
Process design focuses on.pdf
aludin007
 

More from aludin007 (20)

Problem 3 a) A portfolio consisting of Stocks 1 and 2 has an expected.pdf
 Problem 3 a) A portfolio consisting of Stocks 1 and 2 has an expected.pdf Problem 3 a) A portfolio consisting of Stocks 1 and 2 has an expected.pdf
Problem 3 a) A portfolio consisting of Stocks 1 and 2 has an expected.pdf
 
Problem 2. The random variables X and Y have joint probability densil.pdf
 Problem 2. The random variables X and Y have joint probability densil.pdf Problem 2. The random variables X and Y have joint probability densil.pdf
Problem 2. The random variables X and Y have joint probability densil.pdf
 
Problem 3. Using the Probability mass function found below, construct.pdf
 Problem 3. Using the Probability mass function found below, construct.pdf Problem 3. Using the Probability mass function found below, construct.pdf
Problem 3. Using the Probability mass function found below, construct.pdf
 
Problem 2. Prove that the language L2={aib2ii0} is not regular langua.pdf
 Problem 2. Prove that the language L2={aib2ii0} is not regular langua.pdf Problem 2. Prove that the language L2={aib2ii0} is not regular langua.pdf
Problem 2. Prove that the language L2={aib2ii0} is not regular langua.pdf
 
Problem 4 Let X be a uniform (0,1) random variable, and let Y=eX. a. .pdf
 Problem 4 Let X be a uniform (0,1) random variable, and let Y=eX. a. .pdf Problem 4 Let X be a uniform (0,1) random variable, and let Y=eX. a. .pdf
Problem 4 Let X be a uniform (0,1) random variable, and let Y=eX. a. .pdf
 
Problem 3. Graph Q2. Match the graphs with their descriptions. DAG [C.pdf
 Problem 3. Graph Q2. Match the graphs with their descriptions. DAG [C.pdf Problem 3. Graph Q2. Match the graphs with their descriptions. DAG [C.pdf
Problem 3. Graph Q2. Match the graphs with their descriptions. DAG [C.pdf
 
Problem 3. Tree Q1. Choose yes or no to the following statements abou.pdf
 Problem 3. Tree Q1. Choose yes or no to the following statements abou.pdf Problem 3. Tree Q1. Choose yes or no to the following statements abou.pdf
Problem 3. Tree Q1. Choose yes or no to the following statements abou.pdf
 
Problem 2. Solve the following linear problem using the Dual Simplex .pdf
 Problem 2. Solve the following linear problem using the Dual Simplex .pdf Problem 2. Solve the following linear problem using the Dual Simplex .pdf
Problem 2. Solve the following linear problem using the Dual Simplex .pdf
 
Problem 4 (p. 219#12 ). Let W1 and W2 be independent geometric random.pdf
 Problem 4 (p. 219#12 ). Let W1 and W2 be independent geometric random.pdf Problem 4 (p. 219#12 ). Let W1 and W2 be independent geometric random.pdf
Problem 4 (p. 219#12 ). Let W1 and W2 be independent geometric random.pdf
 
Programming II hiding, and .pdf
 Programming II hiding, and .pdf Programming II hiding, and .pdf
Programming II hiding, and .pdf
 
Procedure #2 The experiment has been set up for you. You will observ.pdf
 Procedure #2 The experiment has been set up for you. You will observ.pdf Procedure #2 The experiment has been set up for you. You will observ.pdf
Procedure #2 The experiment has been set up for you. You will observ.pdf
 
Problem Susan Sound predicts that students will learn most effective.pdf
 Problem Susan Sound predicts that students will learn most effective.pdf Problem Susan Sound predicts that students will learn most effective.pdf
Problem Susan Sound predicts that students will learn most effective.pdf
 
Process design focuses on.pdf
 Process design focuses on.pdf Process design focuses on.pdf
Process design focuses on.pdf
 
Problem 9 For each of the following parts, define a grammar (using e.pdf
 Problem 9 For each of the following parts, define a grammar (using e.pdf Problem 9 For each of the following parts, define a grammar (using e.pdf
Problem 9 For each of the following parts, define a grammar (using e.pdf
 
Problem 2. Let X Exponential (), for some 0. Determine the p.d.f. of.pdf
 Problem 2. Let X Exponential (), for some 0. Determine the p.d.f. of.pdf Problem 2. Let X Exponential (), for some 0. Determine the p.d.f. of.pdf
Problem 2. Let X Exponential (), for some 0. Determine the p.d.f. of.pdf
 
Problem 2. Design a PDA to recognize the language over ={0,1},L3={w#z.pdf
 Problem 2. Design a PDA to recognize the language over ={0,1},L3={w#z.pdf Problem 2. Design a PDA to recognize the language over ={0,1},L3={w#z.pdf
Problem 2. Design a PDA to recognize the language over ={0,1},L3={w#z.pdf
 
Problem 8.73 (LO 8-4) (Algo) In 2022. Laureen is currently single. Sh.pdf
 Problem 8.73 (LO 8-4) (Algo) In 2022. Laureen is currently single. Sh.pdf Problem 8.73 (LO 8-4) (Algo) In 2022. Laureen is currently single. Sh.pdf
Problem 8.73 (LO 8-4) (Algo) In 2022. Laureen is currently single. Sh.pdf
 
Problem 8-14 PE Ratio and Stock Price (LG8-7) JP M.pdf
 Problem 8-14 PE Ratio and Stock Price (LG8-7) JP M.pdf Problem 8-14 PE Ratio and Stock Price (LG8-7) JP M.pdf
Problem 8-14 PE Ratio and Stock Price (LG8-7) JP M.pdf
 
Problem 8. (a) Draw a picture representing the alternative hypothesis.pdf
 Problem 8. (a) Draw a picture representing the alternative hypothesis.pdf Problem 8. (a) Draw a picture representing the alternative hypothesis.pdf
Problem 8. (a) Draw a picture representing the alternative hypothesis.pdf
 
Problem 6. Let X be the time between two successive arrivals at the d.pdf
 Problem 6. Let X be the time between two successive arrivals at the d.pdf Problem 6. Let X be the time between two successive arrivals at the d.pdf
Problem 6. Let X be the time between two successive arrivals at the d.pdf
 

Recently uploaded

Recently uploaded (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 

Problem 4 (10 pts) Write a complete C program and create a user defi.pdf

  • 1. Problem 4 (10 pts): Write a complete C program and create a user defined function with the following prototype: int sum_of_digits(int); The function should return the sum of all digits in the given number. For example, if an integer is 932 , the sum of all its digits is 14 . Hint: Use the % operator to extract digits and use the / operator to remove the extracted digit. For instance, 932%10=2 and 932/10=93. In the main function scan an integer number from the user and print the result of sum_of_digits function.