Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,955 questions

51,897 answers

573 users

How to calculate the next multiple of 10 in C#

1 Answer

0 votes
using System;

public class NextMultipleOf10_CSharp
{
	private static int next_multiple_of_10(int n) {
		return (n % 10 == 0) ? n + 10 : n + (10 - n % 10);
	}
	public static void Main(string[] args)
	{
		int[] nums = new int[] {23, 10, 0, 1841};
		int length = nums.Length;

		for (int i = 0; i < length; i++) {
			Console.WriteLine(next_multiple_of_10(nums[i]));
		}
	}
}



/*
run:

30
20
10
1850

*/

 



answered Nov 22, 2024 by avibootz

Related questions

1 answer 65 views
1 answer 68 views
1 answer 63 views
1 answer 71 views
1 answer 74 views
1 answer 61 views
1 answer 51 views
...