answersLogoWhite

0


Best Answer

prompt x

floor(x + .5) -> x

disp x

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that converts a decimal number to nearest integer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a C program that prompts the user for three decimal numbers and prints them trimmed as integer values. For example, if the user informs the values 13.2, 12.5, 102.231, the program prints out 13, 12, 102?

Here's a simple C program that prompts the user for three decimal numbers, converts them to integers, and prints the trimmed integer values: c Copy code #include int main() { double num1, num2, num3; // Prompt the user for three decimal numbers printf("Enter three decimal numbers: "); scanf("%lf %lf %lf", &num1, &num2, &num3); // Convert and print the trimmed integer values int intNum1 = (int)num1; int intNum2 = (int)num2; int intNum3 = (int)num3; printf("Trimmed integer values: %d, %d, %d\n", intNum1, intNum2, intNum3); return 0; } In this program: We declare three variables num1, num2, and num3 to store the decimal numbers entered by the user. We use printf to prompt the user to enter three decimal numbers. We use scanf to read and store the user's input in the variables num1, num2, and num3. We then convert these decimal numbers to integers by casting them using (int) and store them in intNum1, intNum2, and intNum3. Finally, we use printf again to print the trimmed integer values. Compile and run the program, and it will prompt you for three decimal numbers and print their trimmed integer values as requested.


How do you write a Java program to convert a decimal number to an octal number?

public class Dataconversion { public static void main(String[] args) { System.out.println("Data types conversion example!"); int in = 44; System.out.println("Integer: " + in); //integer to binary String by = Integer.toBinaryString(in); System.out.println("Byte: " + by); //integer to hexadecimal String hex = Integer.toHexString(in); System.out.println("Hexa decimal: " + hex); //integer to octal String oct = Integer.toOctalString(in); System.out.println("Octal: " + oct); } }


What is the code of a c program that will read in a positive integer value and determine If the integer is a prime number and If the integer is a Fibonacci number?

see the program


What translation programs converts assembly language programs to object program?

The only translation program that converts assembly language to machine code is an assembler.


How do you write a program to find number of zeros for the given number in c program?

Assuming the number is represented by a decimal integer, initialise a counter to zero, then repeatedly divide the number by 10 and until the number is zero. After each division, examine the remainder. Each time the remainder is zero, increment the counter. If the number is represented by a decimal float, repeatedly multiply by 10 until the value is an integer, then perform the previous algorithm.


Write a program to subtract integer y from integer x?

x -=y;


What is the program that reads and converts the entire program into object code called?

A compiler.


An assembler converts source program into?

An Assembler converts an assembly language source code into machine-specific code.


Is -5 a integer?

1 hour ago my c program said no, but now I know 5 actually is an integer!


A computer program that converts an entire program into machine language at one time is called?

A compiler.


A computer program that converts the entire program into machine language at one time is called?

compiler


How do you round a number 1 decimal place program?

Many computer programs and programming languages have a built-in round function; read the documentation. If there is none, you can also: 1. Multiply by 10 2. To round to an integer: add 0.5 to the result, then apply the integer function 3. Divide the result by 10 again.