Wednesday 10 January 2018

What is Meltdown and Spectre

What is Meltdown and Spectre

Meltdown and Spectre are two major security issues. They impact Intel, ARM and AMD computer chips, Meltdown and Spectre work on personal computers, mobile devices, and in the cloud. They are attack on our computer and break our security. They are different from each one.
Meltdown:-The easier and more serious vulnerability. The ‘Meltdown’ exploits breaks down CPU-level Protections and allows a program to access memory.
 Spectre:-Spectre breaks the isolation between different applications. It allows an attacker to trick error-free programs, which follow best practices, into leaking their secrets.

So what we can do for safety

Microsoft says it released a security update Wednesday to help mitigate the issue. If you're running Windows 10, it should automatically download and install -- but it might depend on your PC's settings. According to Google, a new security update dated Jan. 5 will include "mitigations" to help protect your phone, and future updates will include more such fixes.
So you have to update your mobile phones and laptop. But biggest problem is that what will happen to those devices which are not getting software updates.                         

Wednesday 3 January 2018

Creating a Student Records using Struct and sorting the Record in C#(Sharp)

   Creating a Student Records using Struct in C#(Sharp)

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

namespace Studentinfo
{
    class Program
    {
        /*
         * we are creating the structure of student.
         * using the loop for taking the student record.
         * using the Array.sort() for sorting the values.
         */
        struct student   
        {
            public string Names;
            public DateTime Date;
            public string Class;
        }
             static void Main(string[] args)
            {
                student[] sr = new student[3];
                for (int i = 0; i < sr.Length; i++)
                {
                Console.Write("Enter the Name\t");
                sr[i].Names = Console.ReadLine();
                Console.Write("Enter the DOB\t");
                sr[i].Date = Convert.ToDateTime(Console.ReadLine());
                Console.Write("Enter the Class\t");
                sr[i].Class = Console.ReadLine();
                }
                Console.WriteLine("Sort by Name Press 1 or DOB for 2");
                char val = Convert.ToChar(Console.ReadLine());
                switch (val)
                {
                    case '1': Console.WriteLine("orderd by name"); Array.Sort(sr, (x, y) => String.Compare(x.Names, y.Names)); break;
                    case '2':Console.WriteLine("orderd by dob");Array.Sort(sr, (x1, y1) => DateTime.Compare(x1.Date, y1.Date));break;
                    default:Console.WriteLine("As it is");break;
                }
                for (int i = 0; i < sr.Length; i++)
                {
                    
                    Console.Write("\t Names\t{0}", sr[i].Names);
                    Console.Write("\t DOb\t{0}", sr[i].Date);
                    Console.Write("\t Class\t{0}", sr[i].Class);
                    Console.WriteLine("");
                }
                    Console.ReadLine();
            }

        }
    }


Swap Numbers Program in C#(Sharp)

                Swap Numbers Program in C#(Sharp)

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

namespace swaping2
{
    class Program
    {
        /*
          * we creating the SwapNum function.
          * creating the object obj and call the SwapNum function.
          *  passing the reference values num1 and num2;
       */

        void SwapNum(ref int x, ref int y)  
          {
              x = x + y;
              y = x - y;
              x = x - y;
            Console.WriteLine("Now First number is=>{0} Second is{1}",x,y);
            Console.ReadLine();
          }
            static void Main(string[] args)
            {
                int num1, num2;
                Program obj = new Program();
                Console.Write("enter First numbr");
                num1 = Convert.ToInt16(Console.ReadLine());
                Console.Write("enter Second numbr");
                num2 = Convert.ToInt16(Console.ReadLine());
                obj.SwapNum(ref num1, ref num2);
              

           }
     }
    
}   

Fibonacci Series in C#(Sharp)

                  Fibonacci Series in C#(Sharp)

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

namespace Fibonacciseries
{
   
    class Program
    {
        /* 
         * creating the fab() function.
         * we are storing the values in count for limit of the series.
        */
        static int count;
          void fab()
        {
            int i, f1 = 0, f2 = 1, f3 = 0;
            Console.WriteLine(f1);
            Console.WriteLine(f2);
            for (i = 0; i < count; i++)
            {
                f3 = f1 + f2;
                Console.WriteLine(f3);
                f1 = f2;
                f2 = f3;
            }
            Console.ReadLine();
         }
       
             static void Main(string[] args)
           {
            count = Convert.ToInt16(args[0]);
            Program p = new Program();
            p.fab();
           }
    }
}

Array Sorting Program in C#(Sharp)

            Array Sorting Program in C#(Sharp)

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

namespace ArraySorting
{
    class Program
    {
        static void Main(string[] args)
        {
            /* sorting the Array
               * we are creating the 3 array. arr,asc,desc.
               * arr for storing the array.
               * asc for storing the even numbers.
               * desc for storing the odd numbers.
               * using for loop for accepting the array values,and print the values.
               * we are using the Array.Resize() for creating the asc(array) size in run time.
               * usig Array.Sort() for sorting the array.
               * using Array.Reverse() for reversing the sorting array and sorting the array in descending order.
            */  
            int[] array = new int[10];
            int[] asc = new int[0];
            int[] dsc = new int[0];
            int j = 0, k = 0;

            for (int i = 0; i < 10; i++)
            {

                Console.Write("Enter the number\t");
                array[i] = Convert.ToInt32(Console.ReadLine());
                if (array[i] % 2 == 0)
                {
                    Array.Resize(ref  asc, asc.Length + 1);
                    asc[asc.Length-1] = asc.Length + 1;
                    asc[j] = array[i];
                    j = j + 1;
                }
                else
                {
                    Array.Resize(ref  dsc, dsc.Length + 1);
                    dsc[dsc.Length - 1] = dsc.Length + 1;
                    
                    dsc[k] = array[i];
                    k = k + 1;
                }

                
            }
                Array.Sort(asc);
                Array.Sort(dsc);
                Array.Reverse(dsc);
                int a =asc.Count();
                int b =dsc.Count();

                for (j = 0; j!=(asc.Length) ; j++)
                Console.WriteLine(asc[j]);
                
                for (k = 0; k!=(dsc.Length); k++)
                Console.WriteLine(dsc[k]);
                
                Console.ReadLine();

            
        }
    }
}

Number System Program in C#(sharp)

                        Number System Program in C#(sharp)

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


namespace NumberSystem
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * we are using the if condition to check all numbers are 0 or 1.
             * conveting the string->integer->(base 2)->find binary number.
             * usi .ToString("X"); for intege to hexdecimal value. 
            */
            string dec,binary;
            Console.Write("Enter the Binary Number\t\t");
            binary = Console.ReadLine();
            int bin = Convert.ToInt32(binary);
            bool status = true;
            while (true)
            {
                if (bin == 0){break;}else{ int tmp = bin % 10;
                if (tmp > 1){status = false;break;}bin = bin / 10;}
            }
            if (status == true)
            {
                dec = Convert.ToInt32(binary, 2).ToString();
                Console.WriteLine("Decimal value\t\t\t{0}",dec);
                string strHex = Convert.ToInt32(binary, 2).ToString("X");
                Console.WriteLine("HexaDecimal value\t\t{0}", strHex);
            }
            else
            {
                Console.WriteLine("wrong input");
                Console.ReadLine();
            }


             int  num;
             Console.Write("Enter the Decimal Number\t");
              string m = Console.ReadLine();
              bool isNum1 = int.TryParse(m, out num);
              if (isNum1)
              {
                  string ans = Convert.ToString(num, 2);
                  Console.WriteLine("Binary value\t\t\t{0}", ans);
                  string hexValue = num.ToString("X");
                  Console.WriteLine("HexaDecimal value\t\t{0}", hexValue);
              }
              else
              {
                  Console.WriteLine("Wrong Input");
              }

              Console.Write("Enter the HexaDecimal Number\t");
              string sw = Console.ReadLine();
              bool isHex = sw.All("0123456789abcdefABCDEF".Contains);
              if (isHex)
              {
                  string result = Convert.ToString(Convert.ToInt32(sw, 16), 2).PadLeft(12, '0');
                  Console.WriteLine("Binary value =>\t\t{0}", result);
                  int decValue = Convert.ToInt32(sw, 16);
                  Console.WriteLine("Decimal values is\t{0}", decValue);
              }
              else
              {
                  Console.Write("Wrong Input");
              
              }
             Console.ReadLine();
        }
    }

}

Grade Calculator Program in C#(Sharp)

                    Grade Calculator Program in C#(Sharp)

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

namespace cgpga
{
    class Program
    {
        static void Main(string[] args)
        {
            // creating the program for calculate the CGPA from percentage

            double first, second, third, fourth, fifth,CGPA;
            char option;
            Console.Write("Enter the Number of first subject ");
            first = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter the Number of second subject ");
            second = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter the Number of third subject ");
            third = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter the Number of fourth subject ");
            fourth = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter the Number of fifth subject ");
            fifth = Convert.ToDouble(Console.ReadLine());
            CGPA = ((first + second + third + fourth + fifth) / 5) / 9.5; // we are divide percentage to 9.5 for calculating the CGPA
            Console.WriteLine("Your CGPA is=>"+CGPA);


            if (CGPA >= 8) // checking the condition for the Grad.
            {
    
                option = '1';
           }

            else if (CGPA >= 6.5 && CGPA <8)
           {

                option = '2';

           }

            else if (CGPA >= 3.5 && CGPA < 6.5)

            {

                option = '3';

            }

            else

            {

                option = 'F';

            }
                switch (option)  //checking the condition for the Grad

            {

                case '1': Console.WriteLine("Grade: First Class with Distinction"); break;
                case '2':Console.WriteLine("Grade: second Class");break;
                case '3':Console.WriteLine("Grade: Third Class Class");break;
                case 'F':Console.WriteLine("Grade: Fail");break;
                default:Console.WriteLine("Invalid GRADE");break;

             }       
                Console.ReadLine();
    }
  }
}

Output==>

Give Change Program in C#(Sharp)

                       Give Change Program in C#(Sharp)

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

namespace bills
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Price?");
            int prince = Convert.ToInt32(Console.ReadLine());
            Console.Write("Paid?");
            int paid = Convert.ToInt32(Console.ReadLine());
            int remainder = paid - prince;
            Console.Write("Your change is " + remainder+":");
            int i,a,b,c,d,f,g,h;
            //If the remainder is greater then and equal to 100 then this block is executed.
            while(remainder>=100) 
            {
                // we are using the a variable for counting the number of 100 note.
                a = remainder/100; 
                remainder = remainder%100;

                // we are using FOR loop for printing the "100" a times. a is the variable.
                for (i = 1; i <= a;i++ )
                Console.Write("100"+" ");
            }

            while (remainder >= 50)
            {
                b = remainder / 50;
                remainder = remainder % 50;

                for (i = 1; i <= b; i++)
                Console.Write("50" + " ");
            }
         
            
            while (remainder >= 20)
            {
                c = remainder / 20;
                remainder = remainder % 20;

                for (i = 1; i <= c; i++)
                Console.Write("20" + " ");
            }
         
            
            while (remainder >= 10)
            {
                d = remainder / 10;
                remainder = remainder % 10;

                for (i = 1; i <= d; i++)
                Console.Write("10"+" ");
            }

            while (remainder >= 5)
            {
                f = remainder / 5;
                remainder = remainder % 5;

                for (i = 1; i <= f; i++)
                Console.Write("5"+" ");
            }

            while (remainder >= 2)
            {
                g = remainder / 2;
                remainder = remainder % 2;

                for (i = 1; i <= g; i++)
                Console.Write("2"+" ");
         
           }

            while (remainder >= 1)
            {
                h = remainder / 1;
                remainder = remainder % 1;

                for (i = 1; i <= h; i++)
                Console.Write("1"+" ");
            }
                Console.ReadLine();
       }
    }
}

Exceptions Handling Program in C#(Sharp)

                 Exceptions Handling Program in C#(Sharp)

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

namespace TrappedExceptions
{
    class Program
    {
        
        static void Main(string[] args)
        {
            //  Exceptions  trapped Program
           try{ // using try... catch 
                
                int first, second;
                Console.Write("Enter the first number=>");
                first = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the second number=>");
                second = Convert.ToInt32(Console.ReadLine());
                int  result =  first/second;
                Console.WriteLine(result);
                Console.ReadLine();
             }catch(Exception) 
               {
                Console.WriteLine("Divide by Zero error");// if value is Divide by Zero.
                Console.ReadLine();
               }
        }
     }
  }

Digits in a number Program in C# (Sharp)

                   Digits to number Program in C# (Sharp)

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


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

            Int64 reverse = 0, remainder,reverse1=0;
            //Int64 num = Convert.ToInt64(args[0]);

            Int64 num = Convert.ToInt64(args[0]);
            //Console.WriteLine(num);
            while (num != 0)
            {   
                remainder = num % 10;
                reverse = reverse * 10 + remainder;
                num = num / 10;
           }
            
             Int64 a = reverse;
             
             while (a != 0)
            {
               
                remainder = a % 10;
                reverse1 = reverse1 * 10 + remainder;
                Console.Write(remainder); 
                Console.Write(" ");
                a = a / 10;
                
            }
             Console.Write("\r\n"); 
             Int64 a1 = reverse;
             while (a1 != 0)
             {

                 remainder = a1 % 10;
                 reverse1 = reverse1 * 10 + remainder;
                 Console.WriteLine(remainder);
                 Console.Write("");
                 a1 = a1 / 10;
             }
             Int64 a2 =  Convert.ToInt64(args[0]);
            
             while (a2 != 0)
             {
                 remainder = a2 % 10;
                 Console.Write(remainder);
                 Console.Write(" ");
                 a2 = a2 / 10;
             }
        }
    }
}

Temperature Scale Program in C#(Sharp)

                  Temperature Scale Program in C#(Sharp)

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

namespace TemperatureScale
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Temperature Scale Program 
             
             *  we are using the Replace() for the Removing the C from the use input.
             *  we are  checking the result value it is numeric or not.
             * we are using if statement. if isNum is true then execute the if blcok
             */


            string result = args[0];
            result = result.Replace("C",""); 
            double Num;
            bool isNum1 = double.TryParse(result, out Num);
            if (isNum1)
            {
                double celsius = Convert.ToDouble(result);
                double kelvin = celsius + 273;
                double Fahrenheit = celsius * 18 / 10 + 32;
                Console.WriteLine("{0}K,{1}F", kelvin, Fahrenheit);
            }
            else
            {
                Console.WriteLine("Please input the write Temperature");
            }

        }
    }
}

Multiplication Table Program in C#(Sharp)

               Multiplication Table Program in C#(Sharp)

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

namespace multiplication_table
{
    // multiplication table//
    class Program
    {
        static void Main(string[] args)
        {
            int i, table; // define integer variable
            string Str = args[0]; // get input from commandline and store this value in str variable
            double Num;   // define double value 
            bool isNum = double.TryParse(Str, out Num); // converting string to int if a conversion succeeded then store isNum is true otherwise false
            if (isNum) // if isNum value is true then conversion succeeded 
            {
                table = Convert.ToInt32(args[0]); // convert string value to integer 
                Console.WriteLine("Multiplication table of "+table);
                for (i = 1; i <= 10; i++) // using for loop for table(1...10)
                {
                    int result = table * i; // multiplication with commandline argument and i 
                    Console.WriteLine("{0} X {1} = {2}", table, i, result); // using placeholder to print table,i value and result

                }
                Console.ReadLine();
            }
            else   // if isNum value is false then conversion failed
            {
                Console.WriteLine("Invalid number");
                

            }

        }
    }
}

Simple Calculator Program in C#(sharp)

                   Simple Calculator Program in C#(sharp)

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

namespace calculator
{
    class Program
    {
        static void Main(string[] args)
        {    
            //basic Calculator program//
             double Num,result; //
           
            bool isNum1 = double.TryParse(args[0], out Num); // converting string to double if a conversion succeeded then  isNum is true otherwise false
            bool isNum2 = double.TryParse(args[2], out Num);
            if (isNum1 && isNum2) // if isnum1 and isnum2 is numeric value than execute if block otherwise execute else block
            {
                try
                {

                    char operant = Convert.ToChar(args[1]); // convert string to char
                    switch (operant) // using switch block for checking operant
                    { 
                        case '+':
                            result = double.Parse(args[0]) + double.Parse(args[2]); //add two values
                            Console.WriteLine("{0} + {1} = {2}", args[0], args[2], result); // print result
                            break;
                        case '-':
                            result = double.Parse(args[0]) - double.Parse(args[2]); //add two values
                            Console.WriteLine("{0} - {1} = {2}", args[0], args[2], result); // print result
                            break;
                        case '*':
                            result = double.Parse(args[0]) * double.Parse(args[2]);
                            Console.WriteLine("{0} * {1} = {2}", args[0], args[2], result); // print result
                            break;
                        case '/':
                            result = double.Parse(args[0]) / double.Parse(args[2]);
                            Console.WriteLine("{0} * {1} = {2}", args[0], args[2], result); // print result
                            break;
                        default:
                            Console.WriteLine("Wrong operation"); // if user using the(apart from these +,-,*,/) other operant than print the wrong operation
                            break;
                    }
                    }
                   catch (Exception e)
                  {
                    Console.WriteLine("using calculator with the correct values...");  // handling catching exception
                    Console.WriteLine("Error is that " + e);
                    Console.ReadLine();
                 }
                }
          else
            {
                Console.WriteLine("Wrong operation"); // if args[0] and args[2] is not number then execute else block
            
            }
     
       }
    }
}

Hello World Program in C#

                           Hello World Program in C#

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

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
             //Hello World Program//
            string name;
            Console.Write("Enter your name=>");
            name = Console.ReadLine(); // store user name in name variable
           
          
            if (DateTime.Now.TimeOfDay.TotalHours >= 6 && DateTime.Now.TimeOfDay.TotalHours < 12)// using 24 hour 1-24
            {
                Console.WriteLine("Good Morning " + name);
                Console.ReadLine();
            }
            else if (DateTime.Now.TimeOfDay.TotalHours >= 12 && DateTime.Now.TimeOfDay.TotalHours < 16)
            {

                Console.WriteLine("GoodAfterNoon " + name);
                Console.ReadLine();
            
            }
            else if (DateTime.Now.TimeOfDay.TotalHours >= 16 && DateTime.Now.TimeOfDay.TotalHours < 20)
            {
                Console.WriteLine("Good Evening " + name);
                Console.ReadLine();
            
            }
            else
            {
                Console.WriteLine("Good Night " + name);
                Console.ReadLine();
            }
        }
    }
}

😍Developer on Weekends #shorts #officememes #developermemes

😍Developer on Weekends #shorts #officememes #developermemes Welcome to the latest viral YouTube shorts meme for developers! 😍Developer on...