ODD One out Quiz

Friday, 28 March 2014

C# code to save the image

// code to save the image which is shown in picture box.
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "Image |*.jpg |PNG | *.png";

sa.ShowDialog();

Image.IsAlphaPixelFormat(System.Drawing.Imaging.PixelFormat.Extended);
pictureBox1.Image.Save(sa.FileName);

}

C# code to open the image in Picture box Control

//Code to open the image in picture box
{
OpenFileDialog o = new OpenFileDialog();
  o.ShowDialog();
  pictureBox1.Image = Image.FromFile(o.FileName);
}

C# Code to Subtract two number without using (-) operator

//Program to Subtract two numbers without using subtract (-) operator

int a = 42, b = 13;
int c = a + ~b + 1;

Console.WriteLine("The value of a is " + a + "\n");
Console.WriteLine("The value of b is " + b + "\n");
Console.WriteLine("The Difference of a and b and value of c is "+ c);
Console.ReadKey();



C# Code Examples

Code to Shutdown your computer in button click event in C#

Process.Start("shutdown", "/s /t 0"); //to shut down the computer


Code to open the desktop in C# is written below :- 

You have to write one line of code in button_click event

{
System.Diagnostics.Process.Start("explorer", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
}

Check this Link

http://cashnit.com/?refer=4263
// Program to Add two numbers without using Add (+) operator
int a = 42, b = 13;
int c = a - ~b - 1;

Console.WriteLine("The value of a is " + a + "\n");
Console.WriteLine("The value of b is " + b + "\n");
Console.WriteLine("The Addition of a and b and value of c is " + c);
Console.ReadKey();



Saturday, 22 March 2014

Sunday, 16 March 2014

Browser Application





Browser Application Version 1.0.0 developed by me.. This application will run on any operating system like windows 7, 8, 8.1 and Xp also.

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;
using System.Diagnostics;

namespace Control1
{
    public partial class Browser : Form
    {
        public Browser()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }


        private void button1_Click(object sender, EventArgs e)
        {

            try
            {

                if (textBox1.Text.Contains("www.") || textBox1.Text.Contains(".in"))
                {

                    string target = textBox1.Text;
                    System.Diagnostics.Process.Start(target);// to open a link at default browser

                }
                else
                {
                    MessageBox.Show("Type Correct URI Link");
                }
            }
            catch (FormatException e1)
            {
                MessageBox.Show(e1.Message);
            }


        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {

            
            ProcessStartInfo sInfo = new ProcessStartInfo(e.Link.LinkData.ToString());
            Process.Start(sInfo);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            linkLabel1.Links.Remove(linkLabel1.Links[0]);
            linkLabel1.Links.Add(0, linkLabel1.Text.Length, "https://www.google.co.in");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {

                

                    string target1 = textBox2.Text;
                    System.Diagnostics.Process.Start("IExplore.exe", target1);// to open a link at default browser

               
                
            }
            catch (FormatException e1)
            {
                MessageBox.Show(e1.Message);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            webBrowser1.Url = new System.Uri(textBox3.Text, System.UriKind.RelativeOrAbsolute);
        }
    }

}





Saturday, 15 March 2014

Control Demo Window Application In C#

Control Demo
I developed a window Application in which user can press button to perform some window operations like open my computer, open my documents and sleep, hibernate, shut down and restart the computer.

Tuesday, 11 March 2014

Program to Convert a number to word

Program to convert a number to word..

class Program
    {
        static void Main(string[] args)
        {
            int num;
            int nextdigit;
            int numdigits;
            int[] n = new int[20];
            string[] digits = { "zero", "one", "two",
"three", "four", "five",
"six", "seven", "eight",
"nine" };
            num = 1908;
            Console.WriteLine("Number: " + num);
            Console.Write("Number in words: ");
            nextdigit = 0;
            numdigits = 0;
            // Get individual digits and store in n.
            // These digits are stored in reverse order.
            do
            {
                nextdigit = num % 10;
                n[numdigits] = nextdigit;
                numdigits++;
                num = num / 10;
            } while (num > 0);
            numdigits--;
            // Display the words.
            for (; numdigits >= 0; numdigits--)
                Console.Write(digits[n[numdigits]] + " ");
            Console.WriteLine();
            Console.ReadLine();
        }
    }

Inventors of All Programming languages

Names of Inventors who developed PROGRAMMING LANGUAGES


Joe Armstrong, creator of Erlang.
John Backus, inventor of Fortran.
Alan Cooper, developer of Visual Basic.
Edsger W. Dijkstra, developed the framework for structured programming.
Jean-Yves Girard, co-inventor of the polymorphic lambda calculus (System F).
James Gosling, developer of Oak, the precursor of Java.
Anders Hejlsberg, developer of Turbo Pascal, Delphi and C#.
Rich Hickey, creator of Clojure.
Grace Hopper, developer of Flow-Matic, influencing COBOL.
Kenneth E. Iverson, developer of APL, and co-developer of J along with Roger Hui.
Alan Kay, pioneering work on object-oriented programming, and originator of Smalltalk.
Brian Kernighan, co-author of the first book on the C programming language with Dennis Ritchie, coauthor of the AWK and AMPL programming languages.
Yukihiro Matsumoto, creator of Ruby.
John McCarthy, inventor of LISP.
Bertrand Meyer, inventor of Eiffel.
Robin Milner, inventor of ML, and sharing credit for Hindley–Milner polymorphic type inference.
John von Neumann, originator of the operating system concept.
Martin Odersky, creator of Scala, and previously a contributor to the design of Java.
John C. Reynolds, co-inventor of the polymorphic lambda calculus (System F).
Dennis Ritchie, inventor of C. Unix Operating System, Plan 9 Operating System.
Nathaniel Rochester, inventor of first assembler (IBM 701).
Guido van Rossum, creator of Python.
Bjarne Stroustrup, developer of C++.
Ken Thompson, inventor of B, Go Programming Language, Inferno Programming Language, and Unix Operating System co-author.
Larry Wall, creator of the Perl programming language (see Perl and Perl 6).
Niklaus Wirth, inventor of Pascal, Modula and Oberon.
Stephen Wolfram, creator of Mathematica.

Saturday, 8 March 2014

Tic Tac Toe Game Designed in Graphics

Code of Tic Tac Toe Game in Graphics in OpenGL


#include<GL/gl.h>
#include<GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0,1.0,0.0,0.0);
glLineWidth(10.0);
glBegin(GL_LINES);
glColor3f(1.0,1.0,0.0);
glVertex2f(-0.70,0.2);
glVertex2f(0.70,0.2);
glVertex2f(-0.70,-0.30);
glVertex2f(0.70,-0.30);
glEnd();
glBegin(GL_LINES);
glColor3f(1.0,1.0,0.0);
glVertex2f(0.30,-0.70);
glVertex2f(0.30,0.70);
glVertex2f(-0.20,-0.70);
glVertex2f(-0.20,0.70);
glEnd();
int num_segments=150;
int i;
  

float cx=-0.45,cy=0.40, r=0.15;
  
  glColor3f(1.0,0.0,1.0);
  
  glBegin(GL_LINE_LOOP);
  
for(i=0;i<num_segments;i++)
{
       float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx,y+cy);
}
glEnd();
  
//glLineWidth(15.0);
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(-0.10,0.60);
glVertex2f(0.20,0.30);
glVertex2f(0.20,0.60);
glVertex2f(-0.10,0.30);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(0.40,0.60);
glVertex2f(0.65,0.30);
glVertex2f(0.65,0.60);
glVertex2f(0.40,0.30);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(-0.60,-0.20);
glVertex2f(-0.30,0.10);
glVertex2f(-0.30,-0.20);
glVertex2f(-0.60,0.10);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0);
glVertex2f(-0.60,-0.70);
glVertex2f(-0.30,-0.40);
glVertex2f(-0.60,-0.40);
glVertex2f(-0.30,-0.70);
glEnd();

float cx1=0.05,cy1=-0.50;
  
 // glColor3f(1.0,0.0,1.0);
  
  glBegin(GL_LINE_LOOP);
for(i=0;i<num_segments;i++)
{
       float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx1,y+cy1);
}
glEnd();
  
float cx2=0.50,cy2=-0.50;// 9th Circle
  
 // glColor3f(0.0,0.0,0.0);
  glColor3f(1.0,0.0,1.0);
  glBegin(GL_LINE_LOOP);
for(i=0;i<num_segments;i++)
{
       float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx2,y+cy2);
}
glEnd();
float cx3=0.50,cy3=-0.05;
  
  glColor3f(0.0,0.0,0.0);
  
  glBegin(GL_LINE_LOOP);
for(i=0;i<num_segments;i++)
{
       float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx3,y+cy3);
}
glEnd();
float cx4=0.05,cy4=-0.05;
  //glColor3f(0.0,0.0,0.0);
  
  glColor3f(1.0,0.0,1.0);
  glBegin(GL_LINE_LOOP);
for(i=0;i<num_segments;i++)
{
       float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx4,y+cy4);
}
glEnd();
glFlush();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(150,150);
glutCreateWindow("Displaying Tic Tac Toe");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}





Program to perform all Arithmetic operations over two integer values using Switch Statement In C#.

Code:
class Program
    {
        static void Main(string[] args)
        {
            int a, b,c;
            Console.WriteLine("Enter the first number");
            a = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the second number");
            b = Convert.ToInt32(Console.ReadLine());
            int result;
            while(true)
            {
                Console.WriteLine("Press 0 for Addition");
                Console.WriteLine("Press  1 for Subtraction");
                Console.WriteLine("Press 2 for Multiplication");
                Console.WriteLine("Press  3 for Division");
                Console.WriteLine("Press 4 for Modulus");
                Console.WriteLine("Enter the input");
                c = Convert.ToInt32(Console.ReadLine());
                switch(c)
                {
                    case 0:
                        result = a + b;
                        Console.WriteLine("The result is" + result);
                        break;

                    case 1:
                        result = a - b;
                        Console.WriteLine("The result is" + result);
                        break;

                    case 2:
                        result = a * b;
                        Console.WriteLine("The result is" + result);
                        break;

                    case 3:
                        result = a / b;
                        Console.WriteLine("The result is" + result);
                        break;

                    case 4:
                        result = a % b;
                        Console.WriteLine("The result is" + result);
                        break;
                    default:
                        {
                            Environment.Exit(0);
                            
                            

                        }
                        break;
                

                }

            } 

        }
    }