सामग्री पर जाएँ

कंप्यूटर प्रोग्रामिंग/वेरिएबल/सी शार्प

विकिविश्वविद्यालय से
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Variables and Data Types");
        int i = 1234567890;
        float f = 1.2345678f;
        double d = 1.234567890123456;
        string s = "string";
        
        Console.WriteLine("int: " + i);
        Console.WriteLine("float: " + f);
        Console.WriteLine("double: " + d);
        Console.WriteLine("string: " + s);
        Console.WriteLine("");
        
        Console.WriteLine("Constants");
        const float pi = 3.14159f;
        const string c = "Constant";
        Console.WriteLine(pi + "   " + c);
        Console.WriteLine("");
    
        Console.WriteLine("Arithmetic Operators");
        int a = 3;
        int b = 2;
        Console.WriteLine("a = " + a);
        Console.WriteLine("b = " + b);
        Console.WriteLine("a + b = " + (a + b));
        Console.WriteLine("a - b = " + (a - b));
        Console.WriteLine("a * b = " + (a * b));
        Console.WriteLine("a / b = " + (a / b));
        Console.WriteLine("");
    
        Console.WriteLine("Assignment Operators");
        a += b;
        Console.WriteLine("a += b is " + a);
        a -= b;
        Console.WriteLine("a -= b is " + a);
        a *= b;
        Console.WriteLine("a *= b is " + a);
        a /= b;
        Console.WriteLine("a /= b is " + a);
        Console.WriteLine("");
    
        Console.WriteLine("User Input");
        Console.Write("What is your name? ");
        string username = Console.ReadLine();
        Console.WriteLine("Hello " + username + "!");
    }
}

निम्न कोड मुफ्त ऑनलाइन विकास के वातावरण में से एक में ऊपर कॉपी और पेस्ट करो या अपने खुद के कम्पाइलर/इंटरप्रेटर/आईडीई का उपयोग करें।