C# Simple calculator on Windows application

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MY_first_windows_form_application
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
       

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int num1, num2, res;
            num1 = Convert.ToInt32(textBox1.Text);
            num2 = Convert.ToInt32(textBox2.Text);
            res = num1 + num2;
            label3.Text = res.ToString();
         
        }

        private void button2_Click(object sender, EventArgs e)
        {

            int num1, num2, res;
            num1 = Convert.ToInt32(textBox1.Text);
            num2 = Convert.ToInt32(textBox2.Text);
            res = num1 - num2;
            label3.Text = res.ToString();


        }

        private void button3_Click(object sender, EventArgs e)
        {
            int num1, num2, res;
            num1 = Convert.ToInt32(textBox1.Text);
            num2 = Convert.ToInt32(textBox2.Text);
            res = num1 * num2;
            label3.Text = res.ToString();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            int num1, num2, res;
            num1 = Convert.ToInt32(textBox1.Text);
            num2 = Convert.ToInt32(textBox2.Text);
            res = num1 / num2;
            label3.Text = res.ToString();

        }

        private void button5_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
    }
}

OUTPUT




Continue Reading

c# how to create exception by itself

using System;
using System
.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exceptionhandling_02{

    public class book:ApplicationException{
        public book(string issued)
            : base(issued)
        {
       
        }
       
    }
    public class gain_info {
   
        public string  iss;
        public void get_info()
        {


            Console.WriteLine("WELCOME TOO OXFORD LIBRARY");
            Console.WriteLine("enter your book name");
            iss = Console.ReadLine();
            if (iss == "C#" || iss == "c#")
            {
                throw (new book("OOP BOOK CANT BE ISSUED"));
               
            }
            else
            {

                Console.WriteLine("you have issued this book :{0}", iss);

            }



        }
 
    }
    class program
    {

       
        static void Main(string[] args)
        {
            shuru:
            gain_info obj = new gain_info();

            try {

                obj.get_info();
           
            }
            catch(book e)
            {
                Console.WriteLine("exception caught ",e.Message);
            }
           
            goto shuru;
         

        }
    }
}

OUTPUT



Continue Reading

C# how to use delegetion in your code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


delegate void player();

namespace delegationkeyword
{

    class players
    {
       public  static int choice;
       public  static void list() {
            Console.WriteLine("HERE IS THE LIST OF FIVE PLAYERS");
       Console.WriteLine("1- VIRAT KOHLI   \n 2- STEVEN SMITH \n 3- JOE ROOT \n 4- YOUNUS KHAN  \n 5- kANE WILLIAMSOM");
       Console.WriteLine("now enter favourite player input ");
       choice = Convert.ToInt32(Console.ReadLine());
       if (choice == 1)
       {
       Console.WriteLine("MATCHES= 12  RUNS=1215       AVERAGE= 75.93             S-R=60.41");

      
       }
            if(choice==2){
           
              Console.WriteLine("MATCHES=11   RUNS=1079       AVERAGE=71.93              S-R=58.73");


           
            }
             if(choice==3){

                 Console.WriteLine("MATCHES=17   RUNS=1477          AVERAGE=49.23              S-R=60.70");


           
            }
             if (choice == 4)
             {
                 Console.WriteLine("MATCHES=10   RUNS=673           AVERAGE=37.38              S-R=50.48");


            
            
             }
             if (choice == ){
                 Console.WriteLine("MATCHES=10   RUNS=753           AVERAGE=47.06              S-R=53.4 }

        }  


        static void Main(string[] args)
        {
            player abc = new player(list);
            list();
            Console.ReadKey();
        }
    }

}
OUTPUT



Continue Reading

C# how to use enum keyword

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace enumkeyword
{
    class Program
    {
        enum traffic { red, yellow, green }
        static void Main(string[] args)
        {

            int trafstart = (int)traffic.red;
            int trafmiddle = (int)traffic.yellow;
            int trafend = (int)traffic.green;
            Console.WriteLine("Red {0}",trafstart);
            Console.WriteLine("Yellow {0}", trafmiddle);
            Console.WriteLine("Green {0}",trafend);
          
            Console.ReadKey();

        }
    }

}
Output


Continue Reading

C# how TOO USE exception handling divided by zero expression


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exception_handling_1
{
    class Program
    {
        static void Main(string[] args)
        {

           start :

            Console.WriteLine("WELCOME TOO EXCEPTION HANDLING");
            try
            {

                float a, b,result;
                Console.WriteLine("enter your first number");
                a = float.Parse(Console.ReadLine());
                Console.WriteLine("enter second number");
                b = float.Parse(Console.ReadLine());
                if (b == 0)
                {

                    throw new DivideByZeroException();

                }
                else
                    result = a / b;
                Console.WriteLine("your ans is after division : {0}", result);
            }
           
            catch
            {

                Console.WriteLine("SORRY  Number can't divide by zero ");

            }
            finally {

                Console.WriteLine("thankx for using our calculator");
           
            }
            goto start;

        

        }
    }

}

OUTPUT

Continue Reading

Function Overloading

Code:
#include<iostream>
#include<conio.h>
#include<stdio.h>


using namespace std;// not discussed yet.
// Prototype, Declaration
int Tax_Amount(int house_Sq);
int Tax_Amount(int house_Sq, int Vehicle_CC);
int Tax_Amount(int house_Sq, int Vehicle_CC, char Comercial);

void main(void)
{
int hsq;
int VCC;
char com;
cout<<"\n\n_________Well Come to CDGK Taxation Department System __________ ";
cout<<"\n\n Plesae Enter House SQ :";
cin>>hsq;
cout<<"\n\n Please Enter Vehicle CC : { Enter 0 for N/A } ";
cin>>VCC;
cout<<"\n\n Are These Property Use as Comercial:  { Press y = yes, n = no } ";
    cin>>com;
   // Function Calling Work:
if(VCC==0 && com=='n')
{
   int tax_Payable = Tax_Amount(hsq);
cout<<" \n\n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
}
if(VCC>0 && com=='n')
{
   int tax_Payable = Tax_Amount(hsq,VCC);
cout<<" \n\n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
}
if(VCC>0 && com=='y')
{
   int tax_Payable = Tax_Amount(hsq,VCC,com);
cout<<" \n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
}

}

//Function Defination

int Tax_Amount(int house_Sq)
{
int Tax=(house_Sq*1000);
return Tax;

}

int Tax_Amount(int house_Sq, int Vehicle_CC)
{
     int Tax=(house_Sq*1000)+(Vehicle_CC*100);
return Tax;

}

int Tax_Amount(int house_Sq, int Vehicle_CC, char Comercial)
{
int Tax=(house_Sq*2000)+(Vehicle_CC*200);
return Tax;
}

Continue Reading

Generate Randam Number

Code:
#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<cstdlib>
using namespace std;

int random(int);// Prototype
void main()
{
int a;
cout<<"\n Please enter how many random number you want to generate :";
    cin>>a;
random(a);
getch();

}

int random(int num)
{

if(num<=0)
{
return 0;
}
cout<<"\n ==>> "<<rand();
num--;
random(num);
}
Output:


Continue Reading

C++ Program to Check Whether it is Leap Year or Not

#include<iostream>
#include<conio.h>

using namespace std;

void main()
{
    start:

system("color 0B");

int year;

cout<<"\n\t*>*>*> CHECKING LEAP YEAR <*<*<*\n"<<endl;

cout<<"Enter The Year To Check Wheather it is Leap or Not :";
cin>>year;

if(year%4==0)
{
cout<<"\n\t\t>>> Leap Year <<<"<<endl;
}

else
{
cout<<"\n\t>>> Not Leap Year <<<"<<endl;
}

goto start;

getch();
}
Continue Reading

HTML Style

 HTML Style Attribute

Without styling HTML is incomplete.
syntax of HTML styling is

<tagname style="property:value;">

HTML Text Color

It is very simple to change the color of your  text.

color property use for HTML text color.

Color codes are easily available in internet.You can also use the name of color as use in example

Example

<html>
<body>

<h1 style="color:#009;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>

</body>
</html>

HTML Background Color

Same as the text color you can also change the background colour of your web page.

Example


<html>

 <body style="background-color:#CFC;">

<h1>This is a heading</h1>
<p>This is a paragraph.</p>


 </body>
</html>

HTML Fonts

To change the font of your text, use the  font-family property.

Example

<html>
<body>

<h1 style="font-family:Elephant;">This is a heading</h1>
<p style="font-family:Arial Narrow;">This is a paragraph.</p>

</body>
</html>

HTML Text Size

To change the size of your text, use the  font-size property.

Example

<html>
<body>

<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:180%;">This is a paragraph.</p>

</body>
</html>

HTML Text Alignment

You can also adjust the alignment of our text, use the text-align property.

Example

<html>
<body>

<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>

</body>
</html>

Continue Reading

Simple Insertion Sort technique

void main()
{
int i,j,arr[100],temp=0;

cout<<"###INSERTION SORT###\n\n";

cout<<"Enter The Elements"<<endl;

for(i=0;i<5;i++)
{
cin>>arr[i];
}
cout<<"\n\nEntered Elements are"<<endl;
for(i=0;i<5;i++)
{
cout<<arr[i]<<",";
}
for(i=0;i<5;i++)
{
for(j=0;j<5-i;j++)
{
while(arr[j]<arr[j-1])
{
temp=arr[j-1];
arr[j-1]=arr[j];
arr[j]=temp;
}
}
}
cout<<"\n\nSorted Elements are"<<endl;
for(i=0;i<5;i++)
{
cout<<arr[i]<<",";
}
getch();
}
Continue Reading

Simple Bubble Sort Technique


void main()
{
int i,j,arr[100],temp=0;

cout<<"###BUBBLE SORT###\n\n";

cout<<"Enter The Elements"<<endl;

for(i=0;i<5;i++)
{
cin>>arr[i];
}

cout<<"\n\nEntered Elements are"<<endl;

for(i=0;i<5;i++)
{
cout<<arr[i]<<",";
}
for(i=0;i<5-1;i++)
{
for(j=0;j<5-1-i;j++)
{
while(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}

cout<<"\n\nSorted Elements are"<<endl;

for(i=0;i<5;i++)
{
cout<<arr[i]<<",";
}
getch();
}






Continue Reading