Exercise
Division Of Two Numbers
Objective
Write a C# program to print the result of dividing 24 by 5 on the screen.
Write Your C# Exercise
C# Exercise Example
using System; // Importing the System namespace to use Console functionalities
// Main class of the program
public class Program
{
// Main method where the program execution begins
static void Main()
{
// Declaring two integer variables with values 24 and 5
int num1 = 24;
int num2 = 5;
// Calculating the result of the division of num1 by num2
double result = (double)num1 / num2; // Casting to double for decimal result
// Printing the result of the division to the screen
Console.WriteLine("The result of dividing 24 by 5 is: " + result);
}
}
Explore our set of C# programming exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of C#. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in C#.
This exercise is perfect for learning how to perform complex arithmetic operations in C#. In this program, you will be asked to solve several mathematical operations using d...
This exercise is perfect for learning how to perform a multiplication in C# with numbers entered by the user. In this program, the user will be asked to input two numbers, a...
This exercise is great for learning how to interact with the user in C# and perform basic mathematical operations. In this program, the user will be asked to input three num...
This exercise will help you understand how to perform several basic mathematical operations in C#, such as addition, subtraction, multiplication, division, and calculating t...
This exercise is perfect for learning how to generate multiplication tables dynamically in C#. In this program, the user enters a number, and the program displays the multip...
This exercise is a great opportunity to learn how to calculate the average of several numbers in C#. In this program, the user must enter four numbers, and the program will ...