Q:

Write a C# Sharp program to calculate the largest integral value less than or equal and smallest integral value greater than or equal to a given number

0

Write a C# Sharp program to calculate the largest integral value less than or equal and smallest integral value greater than or equal to a given number.

Expected Output:
Value largest int value smallest int value
Value less than or equal greater than or equal
8.03 9 8
8.34 9 8
0.12 1 0
-0.14 0 -1
-8.1 -8 -9
-8.6 -8 -9

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Text;
namespace exercises {
  class Program {
    public static void Main() {
      decimal[] values = {
        8.03m,
        8.34m,
        0.12m,
        -0.14m,
        -8.1m,
        -8.6m
      };
      Console.WriteLine("  Value       largest int value      smallest int value");
	  Console.WriteLine("  Value       less than or equal     greater than or equal");	  
      foreach(decimal value in values)
      Console.WriteLine("{0,7} {1,16} {2,20}",
        value, Math.Ceiling(value), Math.Floor(value));
    }
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now