Question

In: Computer Science

Write a program in Objective C that takes an integer keyed in from the terminal and...

Write a program in Objective C that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in Eglish. So if the user types 647, the program should display the following:

six

four

seven

Solutions

Expert Solution

C program to convert the number into words

Source Code:

#include<stdio.h>    
#include<stdlib.h>  
int main(){  
long int n,sum=0,m;      
printf("enter the number :");    
scanf("%ld",&n);    
while(n>0)    
{    
m=n%10;    
sum=sum*10+m;    
n=n/10;    
}    
n=sum;    
while(n>0)    
{    
m=n%10;    
switch(m)    
{    
case 1:    
printf("one ");    
break;    
case 2:    
printf("two ");    
break;    
case 3:    
printf("three ");    
break;    
case 4:    
printf("four ");    
break;    
case 5:    
printf("five ");    
break;    
case 6:    
printf("six ");    
break;    
case 7:    
printf("seven ");    
break;    
case 8:    
printf("eight ");    
break;    
case 9:    
printf("nine ");    
break;    
case 0:    
printf("zero ");    
break;    
default:    
printf("tttt");    
break;    
}    
n=n/10;    
}    
return 0;  
}  

The output


Related Solutions

Write a program in C or in Java, that takes an integer value N from the...
Write a program in C or in Java, that takes an integer value N from the command line, generates N random points in the unit square, and computes the distance separating the closest pair of points. A unit square is a square with sides of length 1, at points (0, 0), (0, 1), (1, 0), and (1, 1). If you wish to avoid the command-line processing, you can just assume you will generate a fixed number of points, say between...
C++ Write a program that takes a string and integer as input, and outputs a sentence...
C++ Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input string is "quit". If the input is: apples 5 shoes 2 quit 0 the output is: Eating 5 apples a day keeps your doctor away. Eating 2 shoes a day keeps your doctor away.
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point...
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number separated by commas. Sample output: Bob Marley, 20, 5.2 2. 2. Write a program that asks the user for a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’). Generate a random number of any size, integer or floating point, and combine those three pieces of information...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers for height and width and uses a nested for loop to make a rectangle out of asterixes. The creation of the rectangle (i.e. the nested for loop) should occur in a void function that takes in 2 parameters, one for height and one for width. Make sure your couts match the sample output (copy and paste from those couts so you don't make a...
Write a program that takes an integer N from the command line and uses StdRandom.uniform() to...
Write a program that takes an integer N from the command line and uses StdRandom.uniform() to generate a random sequence of integers be- tween 0 and N – 1. Run experiments to validate the hypothesis that the number of integers generated before the first repeated value is found is ~√?N/2.
Write a program that takes two integer arrays a and b of size n from the...
Write a program that takes two integer arrays a and b of size n from the user, the use a method product to find the product of a and b and return the results after storing them in an array c, then prints the returned results to the screen. (Note: c[i] = a[i] * b[i], for i = 0, ..., n-1) Sample Output: Enter the size of your arrays: 5 Enter the integer values of the first array a: 1...
Write a program that takes in a positive integer as input, and outputs a string of...
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. Ex: If the input is: 6 the output is: 011 6 in binary is...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string....
Write a C program called test that takes one command line argument, an integer N. When...
Write a C program called test that takes one command line argument, an integer N. When we run test: ./test N the program will do this: the parent process forks N child processes each child process prints its process ID, exits the parent process waits for all child processes to exit, then exits
[C] Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
6.19 LAB: Convert to binary - functionsWrite a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:As long as x is greater than 0    Output x % 2 (remainder is either 0 or 1)    x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string.Ex: If the input is:6the output is:110Your program must define and call the following two functions. The IntegerToReverseBinary function...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT