🔒 Closed Another program using C#

Status
Not open for further replies.

Kenji246

Eternal Poster
Since month ko pa naumpisahan yung c#. I will sent some of my work in this programming language. Ang c# ay similarities ni Java na kung saan may iniba lang na parts and function and then mas mabuti na pag-aralan both of programming language para sa susunod ay hindi na mahihirapan sa pag-cocode at gamay nyo na ito pareho.

Basic coding lang po muna hehe sa susunod na yung mga coding na pang formula ni einstein🤣🤣

Enter a number and identify it as a Even or Odd numbers

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace check1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i;
            Console.Write("Enter a Number : ");

            i = int.Parse(Console.ReadLine());
            if (i % 2 == 0)
            {
                Console.Write("Entered Number is an Even Number");
                Console.Read();
            }
            else
            {
                Console.Write("Entered Number is an Odd Number");

                Console.Read();
            }
        }
    }
}

Find The Greatest number in 2 Entered Number

C#:
using System;
class prog
{
    public static void Main()
    {
        int a, b;
        Console.WriteLine("Enter the Two Numbers : ");
        a = Convert.ToInt32(Console.ReadLine());
        b = Convert.ToInt32(Console.ReadLine());
        if (a > b)
        {
            Console.WriteLine("{0} is the Greatest Number", a);
        }
        else
        {
            Console.WriteLine("{0} is the Greatest Number ", b);
        }
        Console.ReadLine();
    }
}

Program to Calculate Acceleration

C#:
using System;
class program
{
    static void Main(string[] args)
    {
        int v, t, acc;
        Console.WriteLine("Enter the Velocity : ");
        v = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter the Time : ");
        t = int.Parse(Console.ReadLine());
        acc = v / t;
        Console.WriteLine("Acceleration : {0}", acc);
    }
}

Compute Average for the Set of values

C#:
using System;
class program
{
    public static void Main()
    {
        int m, i, sum = 0, avg = 0;
        Console.WriteLine("Enter the Number of Terms in the Array ");
        m = int.Parse(Console.ReadLine());
        int[] a = new int[m];
        Console.WriteLine("Enter the Array Elements ");
        for (i = 0; i < m; i++)
        {
            a = int.Parse(Console.ReadLine());
        }
        for (i = 0; i < m; i++)
        {
            sum += a;
        }
        avg = sum / m;
        Console.WriteLine("Average is {0}", avg);
        Console.ReadLine();
    }
}

Program to Accept the Height & Categories

C#:
using System;
class program
{
    public static void Main()
    {
        float height;
        Console.WriteLine("Enter  the Height (in centimeters) \n");
        height = int.Parse(Console.ReadLine());
        if (height < 150.0)
            Console.WriteLine("Dwarf \n");
        else if ((height >= 150.0) && (height <= 165.0))
            Console.WriteLine(" Average Height \n");
        else if ((height >= 165.0) && (height <= 195.0))
            Console.WriteLine("Taller \n");
        else
            Console.WriteLine("Abnormal height \n");
    }
}

Conversion Decimal to Binary

C#:
using System;
class myclass
{
    static void Main()
    {
        int num;
        Console.Write("Enter a Number : ");
        num = int.Parse(Console.ReadLine());
        int quot;
        string rem = "";
        while (num >= 1)
        {
            quot = num / 2;
            rem += (num % 2).ToString();
            num = quot;
        }
        string bin = "";

        for (int i = rem.Length - 1; i >= 0; i--)
        {
            bin = bin + rem;
        }
        Console.WriteLine("The Binary format for given number is {0}", bin);
        Console.Read();
    }
}

Conversion Celcius to Fahrenheit

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace program
{
    class Program
    {
        static void Main(string[] args)
        {
            int celsius, faren;
            Console.WriteLine("Enter the Temperature in Celsius(°C) : ");
            celsius = int.Parse(Console.ReadLine());
            faren = (celsius * 9) / 5 + 32;
            Console.WriteLine("0Temperature in Fahrenheit is(°F) : " + faren);
            Console.ReadLine();
        }
    }

Convert a given number in terms of Year, Day and Weeks

C#:
using System;
class program
{
    public static void Main()
    {
        int ndays, year, week, days, DAYSINWEEK=7;
        Console.WriteLine("Enter the number of days");
        ndays = int.Parse(Console.ReadLine());
        year = ndays / 365;
        week = (ndays % 365) / DAYSINWEEK;
        days = (ndays % 365) % DAYSINWEEK;
        Console.WriteLine("{0} is equivalent to {1}years, {2}weeks and {3}days",ndays, year, week, days);
        Console.ReadLine();
    }
}


From now hangggang dito muna comment lang kayo if gusto nyo pa ng panibago from another language to help some other and it will be good kung iintindihin nyo yung program at pagaaralan how does function it as well.

Sa mga may assignment dyan click nyo to: https://phcorner.org/threads/kahit-load-lang-po-50-or-100.1024061/

Feedback mga lodi :)
 
Status
Not open for further replies.

About this Thread

  • 11
    Replies
  • 884
    Views
  • 9
    Participants
Last reply from:
foxgalano

Trending Topics

Online now

Members online
393
Guests online
3,095
Total visitors
3,488

Forum statistics

Threads
2,328,534
Posts
29,242,843
Members
1,159,887
Latest member
fixhe29271
Back
Top