Pages

Showing posts with label Functions. Show all posts
Showing posts with label Functions. Show all posts

Friday, August 7, 2015

Code for Program that performs selection search in C++ Programming

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

class sel_search
{
int d[50],s,search_val;
public:
void getdata(void);
int search(void);
void display(void);
};

void sel_search :: getdata(void)
{
cout<<endl<<endl;
cout<<"How many size of array you want to create:-";
cin>>s;
cout<<"Enter "<<s<<" Integers\n";
for(int i=0;i<s;i++)
    cin>>d[i];
cout<<"\n\nEnter your search:-";
cin>>search_val;
}

int  sel_search :: search(void)
{
for(int i=0;i<s;i++)
{
    if(d[i]==search_val)
           return(i+1);
}
return(-1);
}

void sel_search :: display(void)
{
int result;
cout<<"\n\n\n";
result=search();
if(result==-1)
    cout<<"\nEntered Search is Illegal\n";
else
    cout<<"\nSearch is Located at "<<result<<" Position";
}

void main()
{
clrscr();
sel_search o1;
o1.getdata();
o1.display();
getch();
}


Monday, July 27, 2015

Code For Maintaining a Telephone Directory In C++

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
#include <conio.h>

class phoneBook{
    char name[20],phno[6];
    public:
    void getdata();
    void showdata();
    char *getname(){ return name; }
    char *getphno(){ return phno; }
    void update(char *nm,char *telno){
        strcpy(name,nm);
        strcpy(phno,telno);
    }
};

void phoneBook :: getdata(){
    cout<<"\nEnter Name : ";
    cin>>name;
    cout<<"Enter Phone No. : ";
    cin>>phno;
}

void phoneBook :: showdata(){
    cout<<"\n";
    cout<<setw(15)<<name;
    cout<<setw(8)<<phno;
}


void main(){
    phoneBook rec;
    fstream file;
    file.open("c:\\phone.dat", ios::ate | ios::in | ios::out | ios::binary);
    char ch,nm[20],telno[6];
    int choice,found=0;
    while(1){
        clrscr();
        cout<<"\n*****Phone Book*****\n";
        cout<<"1) Add New Record\n";
        cout<<"2) Display All Records\n";
        cout<<"3) Search Telephone No.\n";
        cout<<"4) Search Person Name\n";
        cout<<"5) Update Telephone No.\n";
        cout<<"6) Exit\n";
        cout<<"Choose your choice : ";
        cin>>choice;
        switch(choice){
            case 1 : //New Record
                 rec.getdata();
                 cin.get(ch);
                 file.write((char *) &rec, sizeof(rec));
                 break;

            case 2 : //Display All Records
                 file.seekg(0,ios::beg);
                 cout<<"\n\nRecords in Phone Book\n";
                 while(file){
                    file.read((char *) &rec, sizeof(rec));
                    if(!file.eof())
                        rec.showdata();
                 }
                 file.clear();
                 getch();
                 break;

            case 3 : //Search Tel. no. when person name is known.
                 cout<<"\n\nEnter Name : ";
                 cin>>nm;
                 file.seekg(0,ios::beg);
                 found=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    if(strcmp(nm,rec.getname())==0)
                    {
                        found=1;
                        rec.showdata();
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 getch();
                 break;

            case 4 : //Search name on basis of tel. no
                 cout<<"\n\nEnter Telephone No : ";
                 cin>>telno;
                 file.seekg(0,ios::beg);
                 found=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    if(strcmp(telno,rec.getphno())==0)
                    {
                        found=1;
                        rec.showdata();
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 getch();
                 break;

            case 5 : //Update Telephone No.
                 cout<<"\n\nEnter Name : ";
                 cin>>nm;
                 file.seekg(0,ios::beg);
                 found=0;
                 int cnt=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    cnt++;
                    if(strcmp(nm,rec.getname())==0)
                    {
                        found=1;
                        break;
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 else
                 {
                    int location = (cnt-1) * sizeof(rec);
                    cin.get(ch);
                    if(file.eof())
                        file.clear();

                    cout<<"Enter New Telephone No : ";
                    cin>>telno;
                    file.seekp(location);
                    rec.update(nm,telno);
                    file.write((char *) &rec, sizeof(rec));
                    file.flush();
                 }
                 break;
            case 6 : gotoout;
        }
    }
out:
file.close();
}


Tuesday, June 23, 2015

Program to Implement Linear Search Algorithm

#include<iostream.h>
#include<constream.h>
void read(int a[10],int n)
{
                cout<<"reading\n";
                for(int i=0;i<n;i++)
                                cin>>a[i];
}
void display(int a[10],int n)
{
                for(int i=0;i<n;i++)
                                cout<<a[i]<<"\t";
}
void linearsearch ( int a[10],int n  )
{
                int k,flag=0;
                read(a,n);
                display(a,n);
                cout<<"\nenter an element to be search\n";
                cin>>k;
                for(int i=0;i<n;i++)
                {
                                if(a[i]==k)
                                                flag=1;
                                break;
                }
                if(flag==1)
                                cout << "\nsearching is  successful,element is found at position " << i +1<<endl;
                else
                                cout<<"searching not successful\n";
}
void main()
{
                int a[10], n;
                clrscr();
                cout<<"enter n value..\n";
                cin>>n;
                linearsearch(a,n);
                getch();
}


Thursday, June 18, 2015

How To Create Array of Structures

#include <iostream>
#include <string>
#include<conio.h>
#include <sstream>
using namespace std;

struct movies_t {
  string title;
  int year;
} films [3];

void printmovie (movies_t movie);

int main ()
{
  string mystr;
  int n;

  for (n=0; n<3; n++)
  {
    cout << "Enter title: ";
    getline (cin,films[n].title);
    cout << "Enter year: ";
    getline (cin,mystr);
    stringstream(mystr) >> films[n].year;
  }

  cout << "\nYou have entered these movies:\n";
  for (n=0; n<3; n++)
    printmovie (films[n]);
  return 0;
}

void printmovie (movies_t movie)
{
  cout << movie.title;
  cout << " (" << movie.year << ")\n";
}

Wednesday, June 17, 2015

Statistical Analysis and Histogram


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

namespace Statistiacal_Analysis
{
    class data
    {
        //Function  for Mean-----------------------------------------------------------------------------------------
        public int mean(int[] arr, int num)
        {
            int me = 0;
            for (int i = 0; i < num; i++)
            {
                me = me + arr[i];
            }
            me = me / num;
            return me;
        }

        //------------------------------------------------------------------------------------------------------------------
        //Function for Median----------------------------------------------------------------------------------------
        public void median(int[] arr, int num)
        {
            int me = 0;
            // For Even Size Of The Array----------------------------------------------------------------------------
            if (num % 2 == 0)
            {
                me = ((arr[(num / 2) - 1]) + (arr[num / 2])) / 2;

                Console.WriteLine("The Median Is : " + me);
                Console.WriteLine("=======================================================");
            }
            // For Odd  Size Of The Array---------------------------------------------------------------------------
            else
            {
                me = arr[((num + 1) / 2) - 1];

                Console.WriteLine("The Median is : " + me);
                Console.WriteLine("=======================================================");
            }

        }

        //-----------------------------------------------------------------------------------------------------------------
        //Function  for Mode-------------------------------------------------------------------------------------
        public void mode(int[] array, int size)
        {

            int counter = 1;
            int max = 0;
            int Mode = array[0];
            for (int pass = 0; pass < size - 1; pass++)
            {
                if (array[pass] == array[pass + 1])
                {
                    counter++;
                    if (counter > max)
                    {
                        max = counter;
                        Mode = array[pass];
                    }
                }
                else
                    counter = 1; // reset counter.
            }
            Console.WriteLine("The mode is: " + Mode);
            Console.WriteLine("========================================================");
        }

        //------------------------------------------------------------------------------------------------------------------
        //Function for Standerd Deviation--------------------------------------------------------------------------
        public void stanDev(int[] arr, int num)
        {

            double sd = 0.0;
            double power = 2.0;
            double val = 0.0;
            int Mean = mean(arr, num);
            for (int i = 0; i < num; i++)
            {
                val = (arr[i] - Mean);
                sd = sd + (Math.Pow(val, power)) / (num - 1);
            }

            Console.WriteLine("The Standerd Deviation Is : " + (Math.Sqrt(sd)));
            Console.WriteLine("=======================================================");
        }
        //-----------------------------------------------------------------------------------------------------------------
        //Function For Printing Histogram---------------------------------------------------------------------------
        public void histogram(int[] arr, int num)
        {
            string[][] a = new string[num][];
            for (int i = 0; i < num; i++)
            {
                a[i] = new string[arr[i]];
            }
            Console.Write("Element\t\tValue\t\tHistogram\n");
            Console.WriteLine();
            for (int i = 0; i < num; i++)
            {
                Console.Write(i + "\t\t" + arr[i] + "\t\t");
                for (int j = 0; j < arr[i]; j++)
                {
                    if (j % 4 == 0 && j != 0)
                    {
                        a[i][j] += "|";
                    }
                    else
                    {
                        a[i][j] += "*";
                    }
                   
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }
        //-----------------------------------------------------------------------------------------------------------------
    }
}
//------------------------------------------------- Class data ends here---------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Statistiacal_Analysis
    class Program
    {
        //DRIVER METHOD--------------------------------------------------------------------------------------
        static void Main(string[] args)
        {
            data z = new data();
            string s="";
            // Declarations Of  Variables -----------------------------------------------------------------------
            Random r = new Random();
            int a=0;
            // Dynamically Generated Size In  Array-------------------------------------------------------------
            Console.WriteLine("=======================================================");
            Console.WriteLine("\t\t\t      STAISTICAL DATA ANALYSIS");
            Console.WriteLine("=======================================================");
            Console.Write("Enter The Size OF The Array : ");
            a = int.Parse(Console.ReadLine());
            Console.WriteLine("-------------------------------------------------------------------------------");
            int []N=new int[a];

            // Random Numbers Assigned To The Array-----------------------------------------------------------
            for (int i = 0; i < a; i++)
            {
                N[i] = r.Next(0, 9);
                
                Console.WriteLine("The Collected Sample # "+ i +" Is : " + N[i]);                
            }
            Console.WriteLine("=======================================================");
            for (int i = 0; i < a; i++)
            {
                //Sorting The Array In Order To Calculate Mode---------------------------------------------------
                Array.Sort(N);

                //Printing The Sorted Array----------------------------------------------------------------------------
                Console.WriteLine("The Sorted Data Is : " + N[i]);               
            }
          
            //---------------------------------------------------------------------------------------------------------------

            //function call for Mean------------------------------------------------------------------------------------
            Console.WriteLine("=======================================================");
            Console.WriteLine("The Mean Is : "+z.mean(N,a));
            Console.WriteLine("=====================================================");
            //---------------------------------------------------------------------------------------------------------------

            //function call for Median----------------------------------------------------------------------------------
            z.median(N,a);            
            //--------------------------------------------------------------------------------------------------------------
            //function call for Mode------------------------------------------------------------------------------------
            z.mode(N, a);
            //--------------------------------------------------------------------------------------------------------------
            //function call for Standerd Deviation-------------------------------------------------------------------           
            z. stanDev(N, a);            
            //---------------------------------------------------------------------------------------------------------------

            //function call for Histogram-------------------------------------------------------------------------------
            Console.Write("FOR HISTOGRAM PRESS H OR TO CLOSE PRESS ENTER :  ");
            s=Console.ReadLine();
            if (s == "h")
            {
                z.histogram(N, a);
            }
            else
            {
                Environment.Exit(0);
            }

            Console.ReadLine();
            
        }
    }
}

Saturday, June 13, 2015

Write a program to demonstrate private access specifier?


using System;

namespace Example1
{
  class Program
   {
     private void add()
      {
        int num1, num2, result;
        Console.Write("Enter a number:\t");
        num1 = Convert.ToInt32(Console.ReadLine());

        Console.Write("\nEnter second number:\t");
        num2 = Convert.ToInt32(Console.ReadLine());

        result = num1 + num2;
        Console.WriteLine("{0} + {1} = {2}", num1, num2,           result);
      }
     static void Main(string[] args)
      {
        Program p = new Program();
        p.add(); //It is valid, because private add() is           in same class
        Console.ReadLine();
      }
   }
}

Tuesday, June 9, 2015

Visual Calculator in C# Using Classes




System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; 
namespace visual_calculator
{
    class Methods
    {
        public  int Factorial(int input)
        {
            int answer = 0;
            int count = 0;
            if (input > 0)
            {
                count = 1;
                while (count <= input)
                {
                    if (count == 1)
                    {
                        answer = 1;
                        count++;
                    }
                    else
                    {
                        answer = count * answer;
                        count++;
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter only a positive integer.");
            }

            return answer;
        }
        public  void toBin(int dec)
        {
            int count = 0;
            int[] bin = new int[100];

            while (dec > 0)
            {
                bin[count] = dec % 2;    //store Binary value in array bin
                count++;
                dec = dec / 2;  //for moving from unit to ten's or next
            }
            for (int j = count - 1; j >= 0; j--)//for loop for printing the array elements in reverse

                Console.Write(bin[j]);
        }
        //--------------------------------------------------------------------------------------------------------
        public  void toOct(int dec)
        {
            int count = 0;
            int[] oct = new int[100];

            while (dec > 0)
            {
                oct[count] = dec % 8;    //store octal in oct array
                count++;
                dec = dec / 8;           //for moving from unit to ten's or next
            }
            for (int j = count - 1; j >= 0; j--)//for loop for printing the array elements in reverse
            {
                Console.Write(oct[j]);
            }
        }

        //--------------------------------------------------------------------------------------------------------
        public  int toHex(int dec)
        {
            int count = 0;
            int[] hex = new int[100];
            while (dec > 0)
            {
                hex[count] = dec % 16; //store stuff in array hex
                count++;
                dec = dec / 16;
            }
            for (int j = count - 1; j >= 0; j--)    //for loop for printing the array elements in reverse
                if (hex[j] < 10)                //if array element is less than 10 then printing the array element
                {
                    Console.Write(hex[j]);
                }
                else
                    switch (hex[j])   //if array element is greater than 10 then replace 10 with A uptill 15 which is F
                    {
                        case 10:
                            Console.Write('A');
                            break;
                        case 11:
                            Console.Write('B');
                            break;
                        case 12:
                            Console.Write('C');
                            break;
                        case 13:
                            Console.Write('D');
                            break;
                        case 14:
                            Console.Write('E');
                            break;
                        case 15:
                            Console.Write('F');
                            break;
                    }
            return hex[count];
        }
        //------------------------------------------------------------------------------
        public  int BintoDecimal(int des)
        {

            int d;
            double num = 0;
            for (int i = 0; des != 0; i++)
            {
                d = des % 10;
                num += (d) * (Math.Pow(2, i));  //Multiplying number with power of 2 increasing from left to right
                des = des / 10;
            }
            return Convert.ToInt32(num);
        }

        public  void BintoOct(int oct)
        {
            toOct(oct);
        }
        public  void BintoHexa(int oct)
        {
            toHex(oct);
        }
        //-------------------------------------------------------------------------------
        public  int OcttoDes(int des)
        {
            int d;
            double num = 0;
            for (int i = 0; des != 0; i++)
            {
                d = des % 10;
                num += d * (Math.Pow(8, i)); //Multiplying number with power of 8 increasing from left to right
                des = des / 10;
            }
            return Convert.ToInt32(num);
        }
       
        //-------------------------------------------------------------------------------
    }
}

Source code:form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace visual_calculator
{
    public partial class CalculateForm : Form
    {
        int input1,sum=0,sub=0,pro=0,div=0,fact=0,sin=0,cos=0,tan=0,cosec=0,sec=0,cot=0,des,log,oct,pow,tenpow,bin,squ,ans;
        int destohex,mod;
        string hexValue;
        double answer,trig = 0;
        Methods m = new Methods();
        public CalculateForm()
        {
            InitializeComponent();
        }      
      
        private void SqrtButton_Click(object sender, EventArgs e)
        {
            double a=double.Parse(textBox3.Text);
            textBox3.Text = Math.Sqrt(a).ToString();
        }

        private void ReciprocalButton_Click(object sender, EventArgs e)
        {
            float a = 0;
            a = float.Parse(textBox3.Text);
            a = 1 / a;
            textBox3.Text = a.ToString();
        }

        private void PowerButton_Click(object sender, EventArgs e)
        {
            pow = 1;
            input1 = int.Parse(textBox3.Text);
            textBox3.Text = "";           
        }
           private void TenPowButton_Click(object sender, EventArgs e)
        {
                tenpow = 1;
            input1 = int.Parse(textBox3.Text);
            textBox3.Text = "";              
        } 
        private void DivideButton_Click(object sender, EventArgs e)
        {
            div = 1;
            input1 = Convert.ToInt32(textBox3.Text);
            textBox3.Text = "";
        }

        private void MultiplyButton_Click(object sender, EventArgs e)
        {
            pro = 1;
            input1 = Convert.ToInt32(textBox3.Text);
        }

        private void SubtractButton_Click(object sender, EventArgs e)
        {
            sub = 1;
            input1 = Convert.ToInt32(textBox3.Text);
            textBox3.Text = "";
       
            }

        private void AddButton_Click(object sender, EventArgs e)
        {
           
            sum = 1;
           input1= Convert.ToInt32( textBox3.Text); 
            textBox3.Text="";
        }
        private void FactButton_Click(object sender, EventArgs e)
        {
            fact = 1;
            input1 = Convert.ToInt32(textBox3.Text);
        }
        private void ModButton_Click(object sender, EventArgs e)
        {
            mod = 1;
            input1 = Convert.ToInt32(textBox3.Text);
            textBox3.Text = "";

        }
        private void ClearButton_Click(object sender, EventArgs e)
        {
            textBox3.Text = "";
            textBox3.Clear();
        }

        private void ModulasButton_Click(object sender, EventArgs e)
        {
            double a = 0;
            a = double.Parse(textBox3.Text) % double.Parse(textBox3.Text);
           textBox3.Text= a.ToString();
        }
        private void SinButton_Click(object sender, EventArgs e)
        {
            sin = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }     

       private void OneButton_Click(object sender, EventArgs e)
        {
            textBox3.Text +="1";
        }

        private void TwoButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "2";
        }

        private void ThreeButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "3";

        }

        private void button21_Click(object sender, EventArgs e)
        {
            textBox3.Text += "4";

        }

        private void button22_Click(object sender, EventArgs e)
        {
            textBox3.Text += "5";

        }

        private void button23_Click(object sender, EventArgs e)
        {
            textBox3.Text += "6";

        }

        private void button12_Click(object sender, EventArgs e)
        {
            textBox3.Text += "7"; 
        }

        private void button13_Click(object sender, EventArgs e)
        {
            textBox3.Text +="8";
        }

        private void button14_Click(object sender, EventArgs e)
        {
            textBox3.Text += "9";
        }

        private void ZeroButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "0";
        }

        private void AnsButton_Click(object sender, EventArgs e)
        {
        if (sum==1)
            {
                ans = input1 + Convert.ToInt32(textBox3.Text);
                textBox3.Text = ans.ToString();
               
            }
        else if(sub==1)
        {
             ans = input1 - Convert.ToInt32(textBox3.Text);
             textBox3.Text = ans.ToString();

        }
        else if (div == 1)
        {
            ans = input1 / Convert.ToInt32(textBox3.Text);
            textBox3.Text = ans.ToString();
        }
        else if (pro == 1)
        {
            ans = input1 * Convert.ToInt32(textBox3.Text);
            textBox3.Text = ans.ToString();
        }
        else if(mod==1)
        {
            ans = input1 % Convert.ToInt32(textBox3.Text);
            textBox3.Text = ans.ToString();
        }
        else if (fact == 1)
        {
            ans = m.Factorial(int.Parse(textBox3.Text));
            textBox3.Text = ans.ToString();
        }
        else if (pow == 1)
        {
            double a = Convert.ToDouble(input1);
            double b = Convert.ToDouble(textBox3.Text);
            answer= Math.Pow(a,b);
            textBox3.Text = answer.ToString();
        }
        else if(tenpow==1)
        {
            double a=Math.Pow(10,Convert.ToDouble(input1));
            textBox3.Text=a.ToString();
        }
        else if (sin == 1)
        {
            answer = Math.Sin(trig);
            textBox3.Text = answer.ToString();
        }
        else if (cos == 1)
        {
            answer = Math.Cos(trig);
            textBox3.Text = answer.ToString();
        }
        else if (tan == 1)
        {
            answer = Math.Tan(trig);
            textBox3.Text = answer.ToString();
        }
        else if (sec == 1)
        {
            answer = 1/Math.Cos(trig);
            textBox3.Text = answer.ToString();
        }
        else if (cosec == 1)
        {
            answer = 1 / Math.Sin(trig);
            textBox3.Text = answer.ToString();
        }
        else if (cot == 1)
        {
            answer = 1 / Math.Tan(trig);
            textBox3.Text = answer.ToString();
        }
        else if (des == 1)
        {
            textBox3.Text = ans.ToString();
        }
     
        else if (destohex == 1)
        {
            textBox3.Text = hexValue;
        }
        else if (oct == 1)
        {
            textBox3.Text = ans.ToString();
        }
        else if (bin == 1)
        {
            textBox3.Text = hexValue;
        }
        else if (squ == 1)
        {
            double a = Math.Pow(Convert.ToDouble(input1), 2);
            textBox3.Text = a.ToString();
        }
        else if (log == 1)
        {
            double a = Math.Log(trig);
            textBox3.Text = a.ToString();
        }
        }

        private void HexaRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            destohex = 1;
            input1 = int.Parse(textBox3.Text);
            hexValue = input1.ToString("X");
          

          }

        private void OctalRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            oct = 1;
            ans = Convert.ToInt32(textBox3.Text, 8);          
        }

        private void BinaryRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            bin = 1;
            input1 = int.Parse(textBox3.Text);
            hexValue=Convert.ToString(input1,2);
        }
        private void DecimalRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            des = 1;
            input1 = int.Parse(textBox3.Text);
            ans = m.BintoDecimal(input1);

        }

        private void AButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "A";
        }

        private void BButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "B";
        }

        private void CButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "C";
        }

        private void DButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "D";
        }

        private void EButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "E";
        }

        private void FButton_Click(object sender, EventArgs e)
        {
            textBox3.Text += "F";
        }

        private void BackspaceButton_Click(object sender, EventArgs e)
        {
          textBox3.Text = textBox3.Text.Remove(textBox3.Text.Length - 1, 1);
        }

        private void SquareButton_Click(object sender, EventArgs e)
        {
            squ = 1;
            input1 = Convert.ToInt32(textBox3.Text);
            textBox3.Text = "";
        }

        private void CosButton_Click(object sender, EventArgs e)
        {
            cos = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }

        private void TanButton_Click(object sender, EventArgs e)
        {
            tan = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }

        private void SecButton_Click(object sender, EventArgs e)
        {
            sec = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }

        private void CotanButton_Click(object sender, EventArgs e)
        {
            cot = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }

        private void CosecButton_Click(object sender, EventArgs e)
        {
            cosec = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }

        private void LogButton_Click(object sender, EventArgs e)
        {
            log = 1;
            trig = Convert.ToDouble(textBox3.Text);
        }
    }

}