Write Your First Code Using C#

Certainly! Here’s a simple “Hello, World!” program written in the C programming language:

#include <stdio.h>

int main() {
printf(“Hello, World!\n”);
return 0;
}

This program includes the standard input/output library (<stdio.h), defines the main function (which is the entry point for the program), and uses printf to print the “Hello, World!” message to the console. The \n is used to create a newline character, so the message is displayed on a new line.

When you compile and run this code, it will print “Hello, World!” to the console.

Hello @Diwakar-S,

This is definitely AI generated content. But why did you post it here and in a different language than the course you seem to be studying for?

If you do use prompts with an AI generative system such as ChatGPT, you need to be specific and say “C#” not just “C” as they have their own syntax, rules, etc.

First Code using C# :

/*
 * C# Program to Perform all Basic Arithmetic Operations
 */
using System;
using System.Collections.Generic;
using System.Text;
namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int Num1, Num2, result;
            char option;
            Console.Write("Enter the First Number : ");
            Num1 = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter the Second Number : ");
            Num2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Main Menu");
            Console.WriteLine("1. Addition");
            Console.WriteLine("2. Subtraction");
            Console.WriteLine("3. Multiplication");
            Console.WriteLine("4. Division");
            Console.Write("Enter the Operation you want to perform : ");
            option = Convert.ToChar(Console.ReadLine());
            switch (option)
            {
            case '1':
                result = Num1 + Num2;
                Console.WriteLine("The result of Addition is : {0}", result);
                break;
            case '2':
                result = Num1 - Num2;
                Console.WriteLine("The result of Subtraction is : {0}", result);
                break;
            case '3':
                result = Num1 * Num2;
                Console.WriteLine("The result of Multiplication is : {0}", result);
                break;
            case '4':
                result = Num1 / Num2;
                Console.WriteLine("The result of Division is : {0}", result);
                break;
            default:
                Console.WriteLine("Invalid Option");
                break;
            }
            Console.ReadLine();
        }
 
    }

Do you have a question about something?

how to verify my trophy , they show the message “We were unable to verify your trophy from Microsoft’s learning platform”. why?