← Back to C# Course | Chapter 3: Operators | Lesson 1 of 6

Arithmetic Operators कैसे काम करते हैं

Arithmetic operators जोड़ने, घटाने, गुणा करने, भाग देने, और बाकी बचा निकालने के लिए calculator buttons हैं। C# इनका उपयोग आपकी numbers से math करने के लिए करता है।

In this page:

  1. Arithmetic Operators
Syntax
csharp
int result = a + b;
int result = a - b;
int result = a * b;
int result = a / b;   // integer division truncates
int result = a % b;

Arithmetic Operators

C# basic arithmetic के लिए +, -, *, /, और % प्रदान करता है। Integer division किसी भी fractional part को truncate कर देता है, जबकि दो doubles को divide करना precision बनाए रखता है। % operator division का remainder return करता है।

Warning: दो integers को divide करना, जैसे 7 / 2, 3 देता है, 3.5 नहीं — fractional result पाने के लिए एक operand को double में cast करें।

उदाहरण: Arithmetic Operators

markup
using System;

class Program
{
    static void Main(string[] args)
    {
        int a = 7, b = 2;

        Console.WriteLine(a + b);
        Console.WriteLine(a - b);
        Console.WriteLine(a * b);
        Console.WriteLine(a / b);        // integer division
        Console.WriteLine(a % b);        // remainder
        Console.WriteLine((double)a / b); // fractional division
    }
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. दो ints को divide करना और एक decimal result की उम्मीद करना, जबकि 7 / 2 3 है।
  2. किसी integer को zero से divide करना, जो DivideByZeroException फेंकता है।
  3. यह भूल जाना कि % negative left operand के लिए एक negative result return करता है।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.