I need help writing a C programming code.
I am trying to create a program that returns ANY given number's decimal value as an Integer (Whole number).
Examples:
User input: 0.35 Output: 35
User input: 1.465 Output: 465
User input: 10.6054 Output: 6054



Raw_code:
#include<stdio.h>
#include<math.h> //math header file for pow() function
int main(){
// declaring temporary variables
double number, diff, temp_diff;
int num, result = 0;
// taking input from user and stroring it in number variable
scanf("%lf", &number);
// converting number into integer type and storing in num
variable
num = (int)number;
// storing decimal value by substracting integer from input
number
diff = number - num;
// stroring decimal value in another temporary variable
temp_diff = diff;
// making diff greater than zero by multiply it with 10(base)
diff *= 10;
// iter variable for storing count of numbers after decimal
point
int iter = 0;
// while loop for counting numbers after decimal point
// condition is converting diff into integer type , which is true
until number is not zero
while((int)diff){
// incrementing iter by 1
iter += 1;
// storing decimal value in diff
diff = diff - (int)diff;
diff *= 10;
}
// stroring resultant integer in by multiplying decimal value with
10 power iters
result = (int)( temp_diff * pow(10, iter));
printf("%d", result);
}
sorry: it doesn't work for last one
I need help writing a C programming code. I am trying to create a program that...
I am writing C++ code, and I need help for this. Create a program that will convert a decimal value into Roman numeral, and output the result. The program will ask for an integer input, assume all inputs are valid, and the program should not end unless the user tells you to. C++ code.
C++
programming language , I need help writing the code . Please
explain if you can .
Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...
I need help with this C++ assignment. Create a program which will implement the sum of the numbers between 1 and n where n is an integer. When completed, the program will allow the user to input a positive integer (n) then the program will add all numbers between 1 and n (including n) and output the sum. For example, if the user enters 8 then the program will sum the numbers 1 through 8 and will output the sum....
I really need help on this programming problem that am doing in Visual Studio 2019 in C++ Submit your .cpp file as well as the input file, the output file, and the screen shot of all the files tiled next to each other here! Instructions: Write a menu driven program that has three options: Option 1: Write a function that calculates the tax for an iphone. The price and the tax rate should be asked from the user. Input validation:...
I need help with this program. Im trying to use C++ programming language. I want to include my ifstream SimpleCal6.txt and my outFile. CS 317 Calculator Program Write a program to input three values, two floats and an operator print out what were read and the resulting evaluation. The operators to handle are +, -, *, / and ^. The floats are one or more digits in length. The last input is sentinel value 0 + 0; Read a float,...
I need help with this python programming exercise, please!
thanks in advance
Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...
Please help me with the following C Programming project. I am providing the code I used which needs to be reworked to add the following requirements. Here is my code #include<stdio.h> char input; int main() { int i = 0; while (true){ scanf_s("%c", &input); if (input == 'X') break; printf("%c", input); } return 0; } Here are the requirements for the code plus and additional note what the code should have. Goals Understand the ASCII representation of character values. Understand...
I need help writing these 2 programs please include all the indents :) In this programming challenge you are to create two Python programs: randomwrite.py andrandomread.py. One program, randomwrite.py, is to write a set of random numbers to a file. The second program, randomread.py, is to read a set of random numbers from a file, counts how many were read, displays the random numbers, and displays the total count of random numbers. Random Number File Writer (randomwrite.py) Create a program...
I need help writing these functions in C programming.
Write a C function that checks if an array is sorted or not using an iterative approach. Write a C function that checks if an array is sorted or not using a recursive approach Write a C function to reverse the elements of an array. Note you are not allowed to use an 1. additional array to do that Write a C function to find the sum of the elements of...
Hello. I just need help with my c++ code. Write a program that: Creates an integer variable AND an integer pointer variable Ask the user to input an integer value Store the value in the integer variable Print the address of the variable. Make the pointer variable point at the integer value Print the value pointed to by the pointer Print the address of the pointer