Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 5, Problem 6E
Expert Solution & Answer
Check Mark
Program Plan Intro

Program Plan:

  • Include the required files
  • Define the main function
    • Declare the variable “num1”, “num2”, “rt_digit”, “val”.
    • Get the number from the user.
    • Check whether “num1” not equal to “0”.
      • Find the remainder using mod operator.
      • Divide the “number” by “10”.
      • Multiply “val” to “num” and add with the “rt_digit”.
      • Condition for while loop to check whether the “val” not equals to “10”.
        • Multiply the “val” with “10”.
      • Assign the “rt_digit” to “0”.
      • Do until the condition fails.
        • Find the remainder using mod operator.
        • Check whether the “rt_digit” equals to “1”.
          • Print the value “one”.
        • Check whether the “rt_digit” equals to “2”.
          • Print the value “two”.
        • Check whether the “rt_digit” equals to “3”.
          • Print the value “three”.
        • Check whether the “rt_digit” equals to “4”.
          • Print the value “four”.
        • Check whether the “rt_digit” equals to “5”.
          • Print the value “five”.
        • Check whether the “rt_digit” equals to “6”.
          • Print the value “six”.
        • Check whether the “rt_digit” equals to “7”.
          • Print the value “seven”.
        • Check whether the “rt_digit” equals to “8”.
          • Print the value “eight”.
        • Check whether the “rt_digit” equals to “9”.
          • Print the value “nine”.
        • While loop to check the condition whether the “num2” not equal to “0”.
Program Description Answer

Program to display the numbers to their equivalent words.

Explanation of Solution

Program:

//Include required header files

#include <stdio.h>

//Main function

int main()

{

//Declare the required variable

int num1 = 0, rt_digit = 0, num2 = 0, val = 1;

//Get the number from the user

printf("\nEnter a number: ");

scanf("%i", &num1);

//While loop to check the condition

while (num1 != 0)

{

//Find the remainder using mod operator

rt_digit = num1 % 10;

//Divide the "num1" by "10"

num1 = num1 / 10;

//Multiply "val" to "num" and add with the "rt_digit"

num2 = num2 * val + rt_digit;

//While loop to check the condition

while (val != 10)

{

//Multiply "val" with "10"

val = val * 10;

}

}

//Assign the "rt_digit" to "0"

rt_digit = 0;

//Do until the condition fails

do {

//Find the remainder using mod operator

rt_digit = num2 % 10;

//Check whether the "rt_digit" equals to "0"

if (rt_digit == 0)

{

//Print the value zero

printf("zero ");

}

//Check whether the "rt_digit" equals to "1"

else if (rt_digit == 1)

{

//Print the value one

printf("one ");

}

//Check whether the "rt_digit" equals to "2"

else if (rt_digit == 2)

{

//Print the value two

printf("two ");

}

//Check whether the "rt_digit" equals to "3"

else if (rt_digit == 3)

{

//Print the value three

printf("three ");

}

//Check whether the "rt_digit" equals to "4"

else if (rt_digit == 4)

{

//Print the value four

printf("four ");

}

//Check whether the "rt_digit" equals to "5"

else if (rt_digit == 5)

{

//Print the value five

printf("five ");

}

//Check whether the "rt_digit" equals to "6"

else if (rt_digit == 6)

{

//Print the value six

printf("six ");

}

//Check whether the "rt_digit" equals to "7"

else if (rt_digit == 7)

{

//Print the value seven

printf("seven ");

}

//Check whether the "rt_digit" equals to "8"

else if (rt_digit == 8)

{

//Print the value eight

printf("eight ");

}

//Check whether the "rt_digit" equals to "9"

else

//Print the value nine

printf("nine ");

//Divide the "num2" by "10"

num2 = num2 / 10;

//While loop to check the condition

} while (num2 != 0);

//Return the value 0

return 0;

}

Sample Output

Enter a number:  56

five six 

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
help me with this project. provide what I should put on each slide (words, example images, etc); example Slide 1: Intro. here are the directions: Submit a report that includes the source code, compiled code, description of the algorithm(s) implemented, data structures used, implementation details including time complexity analysis, sample inputs/outputs, and a conclusion section.
These questions are for a Computer Science course called "Theory of Computation". Provide the answers and process to the answers by using steps without little to no explanations. Provide drawings if necessary based on the questions for 1, 2a-c, and 3 based on these images provided.
Objective: The objective of this assignment is to gain practice with pen testing a live web application running on a remote server. The live web application is a known vulnerable web application called DVWA (Damn Vulnerable Web Application) with security settings set to low. The web app is running on an AWS EC2 (Elastic Compute Cloud) instance running Ubuntu 22. Note: The point of this assignment is to step it up a notch, we learnt about different web application vulnerabilities and applied that knowledge, now we are going to pen test and enumerable the vulnerabilities of a web app + the underlying infrastructure it is running on. Before you begin please find out what your IP address is and place it in this sheet so that I can track who is doing what: IP Addresses.docx . Tasks: 1- Start by connecting to the target, I did not install a TLS certificate on purpose that is why you are going to connect via http and not via https: http://3.99.221.134/dvwa/login.php 2- Broken Authentication:…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY