• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Home
  • How To’s
  • Lifestyle
  • Sports
  • Photography
  • Courses
  • Contact Us
  • SnazzyMedia Team

Snazzy Media

your world amplified!

  • Disclaimer
  • Privacy
  • Contact Us

.NET

C# Programming Exercises, Practice, Solution

September 30, 2016

What is C#?

C# (pronounced “C sharp”) is an object-oriented language that enables developers to build a variety of secure and well made applications that run on the .NET Framework. C sharp is based on C++ and contains features similar to those of Java.

You can use C sharp to create Windows client applications, XML Web services, client-server applications, database applications and much more. C sharp syntax is highly expressive, simple and easy to learn.

The best way to learn anything is by practice. We have started this module for those who are familiar with C sharp programming. Our main aim is to improve your programming coding skills. Enjoy Coding Happy Coding!

Lessons: 

1 : Getting started with C#

2 : Variables and Data types

3 : Flow Control

4 : Constructs

5 : Arrays and Structures

6 : Functions

7 : Object-Oriented Programming

8 : Abstract Classes

9 : File Management

10 : Object Persistence


 

Filed Under: C#, Courses Tagged With: .NET, C#, Programming

C# Exercises and Solutions

September 30, 2016

Lesson 1: Getting started with C#


  • 1.1 – First Program in C#

  • 1.2 – Addition 

  • 1.3 – Subtraction

  • 1.4 – Multiplication

  • 1.5 – Division

  • 1.6 – Use of Placeholders {0}

  • 1.7 – Multiple operations with same numbers 

  • 1.8 – Multiple operations with different numbers

  • 1.9 – Average 

  • 1.10 – Simple multiplication table

  • 1.11 – Swap two numbers


                                                HOME


 

Filed Under: C#, Courses Tagged With: .NET, C#, Programming

Multiplication Table; C# Exercises and Solutions

September 30, 2016

1.10 Simple multiplication table

Question


Write a program to accept a number and display its multiplication table in format given below.

9 * 1 = 9

..

…

9 * 10 = 90


Solution


class MultiplicationTable
    {
        static void Main(string[] args)
        {
            int num;
            int result;            Console.Write(“Enter a number : “);
            num = Convert.ToInt16(Console.ReadLine());            result = num * 1;
            Console.WriteLine(“{0} * {1} = {2}”, num, 1, result);
            result = num * 2;
            Console.WriteLine(“{0} * {1} = {2}”, num, 2, result);
            result = num * 3;
            Console.WriteLine(“{0} * {1} = {2}”, num, 3, result);
            result = num * 4;
            Console.WriteLine(“{0} * {1} = {2}”, num, 4, result);
            result = num * 5;
            Console.WriteLine(“{0} * {1} = {2}”, num, 5, result);
            result = num * 6;
            Console.WriteLine(“{0} * {1} = {2}”, num, 6, result);
            result = num * 7;
            Console.WriteLine(“{0} * {1} = {2}”, num, 7, result);
            result = num * 8;
            Console.WriteLine(“{0} * {1} = {2}”, num, 8, result);
            result = num * 9;
            Console.WriteLine(“{0} * {1} = {2}”, num, 9, result);
            result = num * 10;
            Console.WriteLine(“{0} * {1} = {2}”, num, 10, result);
        }     
    }

 Previous                                              Home                                                     Next


Output10


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Average; C# Exercises and Solutions

September 30, 2016

1.9 – Average

Question


Write a program to accept 3 numbers and calculate the average.

Solution


class Average
    {
        static void Main(string[] args)
        {
            int a, b, c;
            float avg;
            Console.Write(“Enter first number : “);
            a = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter second number : “);
            b = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter third number : “);
            c = Convert.ToInt16(Console.ReadLine());            avg = (float)(a + b + c) / 3.0f;            //Typecasting
            Console.WriteLine(“Average of given numbers is {0:f}”, avg); //{0:f} means decimal upto 2 places
        }
    }

 Previous                                                Home                                                   Next


Output

9


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Multiple Operations; C# Exercises and Solutions

September 30, 2016

1.8 – Multiple operations with different numbers

Question


Write a program to print a result of following operations

25 / 4 + 8

8 + 23 / 4 * 1 – 6 % 2

(36 + 4 – 3) * 2 / 3

-1 * 3 – 5 / 3


Solution

class MultipleOperations
    {
        static void Main(string[] args)
        {
            Console.WriteLine(25 / 4 + 8);       //write given equation inside the brackets in console.writeline, thats it.
            Console.WriteLine(8 + 23 / 4 * 1 – 6 % 2);
            Console.WriteLine((36 + 4 – 3) * 2 / 3);
            Console.WriteLine(-1 * 3 – 5 / 3);        }
    }

 Previous                                                Home                                                   Next


Output

8


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Multiple operations; C# Exercises and Solutions

September 30, 2016

1.7 – Multiple operations with same numbers

Question


Write a program to accept two numbers from user and perform Addition, Subtraction, Multiplication and Division(Remainder and Quotient) and display in format given below

for ex.  enter first number = 13

enter second number = 4

13 + 4 = 17

13 – 4 = 9

13 * 4 = 52

13 / 4 = 3

13 % 4 = 1


Solution


class SameNumbersMultipleOperations
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e, f, g;                  //initialization
            Console.Write(“Enter first number : “);
            a = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter second number : “);
            b = Convert.ToInt16(Console.ReadLine());
            c = a + b;                      //calculation for addition     
            d = a – b;                      //calculation for subtraction
            e = a * b;                      //calculation for multiplication
            f = a / b;                      //calculation for quotient
            g = a % b;                      //calculation for remainder
            Console.WriteLine(“{0} + {1} = {2}”, a, b, c);
            Console.WriteLine(“{0} – {1} = {2}”, a, b, d);
            Console.WriteLine(“{0} * {1} = {2}”, a, b, e);
            Console.WriteLine(“{0} / {1} = {2}”, a, b, f);
            Console.WriteLine(“{0} % {1} = {2}”, a, b, g);
        }
    }

 Previous                                                Home                                                   Next


Output

7


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Division; C# Exercises and Solutions

September 30, 2016

1.5 Division

Question


Write a program which accept two numbers, perform Division and print Quotient and Remainder.

Solution


class Division
    {
        static void Main(string[] args)
        {
            int a, b, c, d;                               //initialization
            Console.Write(“Enter first number : “);
            a = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter second number : “);
            b = Convert.ToInt16(Console.ReadLine());
            c = a / b;                                //calculation for quotient
            d = a % b;                                //calculation for remainder
            Console.WriteLine(“Quotient = “ + c);
            Console.WriteLine(“Remainder = “ + d);    
        }
    }

 Previous                                                Home                                                   Next


Output

5


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Multiplication; C# Exercises and Solutions

September 30, 2016

1.4 Multiplication

Question


Write a program which accept two numbers, perform Multiplication and print their Result.

Solution


class Multiplication
    {
        static void Main(string[] args)
        {
            int a, b, c;                               //initialization
            Console.Write(“Enter first number : “);
            a = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter second number : “);
            b = Convert.ToInt16(Console.ReadLine());
            c = a * b;                                //calculation
            Console.WriteLine(“Multiplication = “ + c);
        }
    }

 Previous                                                Home                                                   Next


Output

Multiplication


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

Subtraction; C# Exercises and Solutions

September 30, 2016

1.3 subtraction

Question


Write a program which accept two numbers and print their subtraction.

Solution


class Subtraction
    {
        static void Main(string[] args)
        {
            int a, b, c;                               //initialization
            Console.Write(“Enter first number : “);
            a = Convert.ToInt16(Console.ReadLine());
            Console.Write(“Enter second number : “);
            b = Convert.ToInt16(Console.ReadLine());
            c = a – b;                                //calculation
            Console.WriteLine(“Subtraction = “ +c);
        }
    }

 Previous                                                Home                                                  Next


Output

3


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

First Program; C# Exercises and Solutions

September 30, 2016

1.1 – First Program in C#

Question


Write a program to print Hello on screen and then print Welcome to Snazzymedia in next line.

Solution


class FirstProgram
    {
        static void Main(string[] args)
        {
            Console.WriteLine(“Hello”);
            Console.WriteLine(“Welcome to Snazzymedia”);
        }
    }

 Previous                                               Home                                                    Next


Output

1


 

Filed Under: Uncategorized Tagged With: .NET, C#, Programming

  • Page 1
  • Page 2
  • Next Page »

Primary Sidebar

Recent Posts

  • Aegon Life Insurance re-announces its Unique and beneficial “iTerm” online Protection plan
  • Vivo V5 : 20 MP Front Camera for a Perfect Selfie
  • A Flying Jatt : Our Desi SuperHero with some Desi Moves
  • Honor launches Honor 8, Honor 8 Smart and Holly 3 in India
  • How to Remove a Bubble Gum from your Shoe?

Recent Comments

  • kolly on Samsung launches Galaxy J7 Prime and J5 Prime in India
  • Jay on GOQii Band 2.0 : The best in class fitness band with USB charging for the first time!

Categories

  • Android Apps
  • C#
  • Courses
  • Featured
  • Fitness
  • Gadgets
  • Health & Fitness
  • How To
  • Lifestyle
  • Science
  • Space
  • Sports
  • Travel
  • Uncategorized
  • Video

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Copyright© 2021 · by Shay Bocks