SlideShare a Scribd company logo
1 of 12
CONSOLE PROGRAMS
                                                                  By: Yasir A k

PROGRAM 01: (Print Name)

static void Main(string[] args)
        {
            Console.WriteLine("Welcome");

        //Console is a built-in class that contains the methods for displaying messages on the
        // screen and getting input from the keyboard.
                string name;
                Console.Write("Enter Your Name: ");
                name = Console.ReadLine();                                // Input
                Console.WriteLine("Your Name Is: " + name);
                Console.ReadKey(); // to hold output like getch()
                    }




PROGRAM 02: (Print Integer)

static void Main(string[] args)
{
            int myInteger;
            string myString;
            myInteger = 17;
            myString = ""My Integer" is";
            Console.WriteLine(myString +" "+ myInteger);
            Console.ReadKey();
        }




PROGRAM 03: (Addition, Subtraction, Multiplication and Division of a Number)

  static void Main(string[] args)
        {
            double firstNumber, secondNumber;
            string userName;
            Console.WriteLine("Enter your Name: ");
            userName = Console.ReadLine();
            Console.WriteLine("Welcome "+ userName);
            Console.WriteLine("Now give me a number:");
            firstNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Now give me another number:");
            secondNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber,
            secondNumber, firstNumber + secondNumber);
            Console.WriteLine("The result of subtracting {0} from {1} is {2}.",
            secondNumber, firstNumber, firstNumber - secondNumber);
            Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber,
            secondNumber, firstNumber * secondNumber);
            Console.WriteLine("The result of dividing {0} by {1} is {2}.",
            firstNumber, secondNumber, firstNumber / secondNumber);
            Console.WriteLine("The remainder after dividing {0} by {1} is {2}.",
            firstNumber, secondNumber, firstNumber % secondNumber);
            Console.ReadKey();
        }




          Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 04: (Marks Sheet)

static void Main(string[] args)
        {
            int phy, maths,eng,cp,isl;
            int total;
            double per;

              Console.WriteLine("nttt MARKS CERTIFICATE ");
              Console.Write("nEnter Physics Marks:");
              phy = Convert.ToInt32(Console.ReadLine());
              Console.Write("nEnter Mathematics Marks:");
              maths = Convert.ToInt32(Console.ReadLine());
              Console.Write("nEnter English Marks: ");
              eng = Convert.ToInt32(Console.ReadLine());
              Console.Write("nEnter Programming Marks:");
              cp = Convert.ToInt32(Console.ReadLine());
              Console.Write("nEnter Islamiat Marks:");
              isl = Convert.ToInt32(Console.ReadLine());

              total = phy + maths+ isl + cp +eng;
              per = (total * 100) / 550;
              Console.WriteLine("Total is: "+Convert.ToInt32(total));
              Console.WriteLine("Percentage is: {0} %" , Convert.ToDouble(per));

              Console.WriteLine("n");
              if (per > 80.0)
                   Console.WriteLine("You Got Grade: A1 ");
              else
                   if (per > 70.0)
                        Console.WriteLine("You Got Grade: A");
                   else
                        if (per > 60.0)
                             Console.WriteLine("You Got Grade: B");
                        else
                             if (per > 50.0)
                                  Console.WriteLine("You Got Grade: C");
                             else
                                  if (per < 49.9)
                                      Console.WriteLine("Your Fail");

              Console.WriteLine("nnttThis Software is Developed By: Yasir Ahmed Khan");
              Console.ReadKey();
         }

PROGRAM 05: Table using For Loop

  static void Main(string[] args)
        {
            int tab_no;

              Console.WriteLine("ntttTable Generatorn");
              Console.Write("Enter Table No: ");

              tab_no = Convert.ToInt32(Console.ReadLine());

              for(int x=1; x<=10;x++)
              {

                  Console.WriteLine("n{0} * {1} = {2}",tab_no,x,(tab_no*x) );

                      }
              Console.ReadKey();
         }




          Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 06: Sum of Two Number’s

{
               int number1, number2, sum;

               Console.Write("Enter First No:");
               number1 = Convert.ToInt32(Console.ReadLine());
               Console.Write("Enter Second No:");
               number2 = Convert.ToInt32(Console.ReadLine());
               sum = number1 + number2;

               Console.Write("Sum is " + sum);


               Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
               Console.ReadKey();

         }

PROGRAM 07: Cities Temperature

{
               double nshah, khi, hyd, multan, isd, lahore, average;

               Console.WriteLine("nnttt AVERAGE TEMPERATURE");
               Console.Write("nEnter Temperature of Nawabshah City :");
               nshah = Convert.ToDouble(Console.ReadLine());
               Console.Write("nEnter Temperature of Hyderabad City :");
               hyd = Convert.ToDouble(Console.ReadLine());
               Console.Write("nEnter Temperature of Multan City :");
               multan = Convert.ToDouble(Console.ReadLine());
               Console.Write("nEnter Temperature of Islamabad City :");
               isd = Convert.ToDouble(Console.ReadLine());
               Console.Write("nEnter Temperature of Lahore City :");
               lahore = Convert.ToDouble(Console.ReadLine());
               Console.Write("nEnter Temperature of Karachi City :");
               khi = Convert.ToDouble(Console.ReadLine());

               average = (nshah + hyd + multan + isd + lahore) / 6;

               Console.WriteLine("nnAVERAGE TEMPERATURE IS: " + average);

               Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
               Console.ReadKey();

         }

PROGRAM 08: Square & Cube of a Number

{

               int num,square,cube,sq_root;

               Console.Write("Enter Number: ");
               num = Convert.ToInt32(Console.ReadLine());

               square = num * num;
               cube = square * num;

            Console.WriteLine("nn Square is " + square);
            Console.WriteLine("nn Cube is " + cube);
Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");

               Console.ReadKey();
        }




            Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 09: Number Compression

    {

             int num1, num2;

             Console.Write("nntt COMPARISSION B/W TWO NUMBER's");

             Console.Write("nnEnter Ist Number ");
             num1 = Convert.ToInt32(Console.ReadLine());

             Console.Write("Enter IInd Number ");
             num2 = Convert.ToInt32(Console.ReadLine());

             if (num1 == num2)
                 Console.WriteLine(num1+" is Equals to "+num2);

             if(num1>num2)
                 Console.WriteLine(num1 + " is Greater Than " + num2);


             if (num1 < num2)
                 Console.WriteLine(num1 + " is Less Than " + num2);

             if (num1 != num2)
                 Console.WriteLine(num1 + " is Not Equals to " + num2);

             if (num1 >= num2)
                 Console.WriteLine(num1 + " is Greater Than or equals to " + num2);

             if (num1 <= num2)
                 Console.WriteLine(num1 + " is Less Than or equals to " + num2);

             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
             Console.ReadKey();
         }

PROGRAM 10: Kilo Meter to meter

{
             int meter, km;

             Console.Write("nntt Enter Value in Kilo Meter ");


             km = Convert.ToInt32(Console.ReadLine());

             meter = km * 1000 ;

             Console.Write("nntt The Value in Meter Is " + meter);


             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
             Console.ReadKey();
         }




         Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 11: Age Analyzer

{
             int year, month,day;

             Console.Write("nntt Enter The Age in Year ");


             year = Convert.ToInt32(Console.ReadLine());

             Console.Write("nntt Enter The Age in MOnth ");


             month = Convert.ToInt32(Console.ReadLine());

             day = year * 365 + month *30 ;

                  Console.Write("nntt Your " + day + " days old");


             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
             Console.ReadKey();

         }

PROGRAM 12: KB to Byte Conversion

{
             int bit,kb;

             Console.Write("nntt Enter The Data Size in Kilo Bytes ");

             kb = Convert.ToInt32(Console.ReadLine());

             bit = kb * 1024 ;
              Console.Write("nntt Your Data Size is " + bit + " Byte ");


             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");
             Console.ReadKey();

       }
PROGRAM 13: Temperature Conversion

        static void Main(string[] args)
         {
             //Temperature of a city in Fahrenheit degrees is input through the keyboard.
             //Write a program to convert this temperature into Centigrade degrees.

             double temp_f, temp_c;
             Console.WriteLine("Enter Your City Temperature: ");
             temp_f = double.Parse(Console.ReadLine());
             temp_c = (temp_f - 32) * 5 / 9;
             Console.WriteLine("Temperature in Celsius is : " + temp_c);
             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");

             Console.ReadKey();

    }




         Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 14: Conversion of Length

static void Main(string[] args)
        {
             //The distance between two cities (in km.) is input through the keyboard.
             //Write a program to convert and print this distance in meters, feet, inches and
centimeters.

             double km, m, feet, inches, centimeter;

             Console.Write("Enter Distance B/w Two Cities in Kilo Meter: ");
             km = double.Parse(Console.ReadLine());

             m = km * 1000;
             feet = m * 3.28084;
             centimeter = m * 100;
             inches = m * 39.37008;

             Console.WriteLine("Distance in Km : " + km);
             Console.WriteLine("Distance in m : " + m);
             Console.WriteLine("Distance in feet : " + feet);
             Console.WriteLine("Distance in centimeter : " + centimeter);
             Console.WriteLine("Distance in inches : " + inches);
             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");

             Console.ReadKey();
}

PROGRAM 15: Salary Sheet

static void Main(string[] args)
        {
            //Ramesh’s basic salary is input through the keyboard.
            //His dearness allowance is 40% of basic salary, and house rent allowance is 20% of
basic salary.
            //Write a program to calculate his gross salary.

             int basic_salary;
             double dearnesss_allowance, house_rent_allowance, gross_salary;

             Console.Write("nn ttPlease Enter Your Basic Salary: ");
             basic_salary = int.Parse(Console.ReadLine());

             dearnesss_allowance = (basic_salary * 0.4);
             house_rent_allowance= (basic_salary * 0.2);
             gross_salary = dearnesss_allowance + house_rent_allowance + basic_salary;

             Console.WriteLine("n ttBasic Salary: " + basic_salary);
             Console.WriteLine("n ttDearness Allowance: " + dearnesss_allowance);
             Console.WriteLine("n ttHouse Rent Allowance: " + house_rent_allowance);
             Console.WriteLine("n ttGross Salary: " + gross_salary);
             Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan");

             Console.ReadKey();
         }




         Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 16: Age Analyzer

static void Main(string[] args)
        {
            int age, days, month;
            Console.WriteLine("give your age progarme will convert it into days");
            Console.WriteLine("give your age in years");

            age = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("give your age in months");
            month = Convert.ToInt32(Console.ReadLine());
            days = age * 365 + month * 30;
            Console.WriteLine("conversion successful,the days will be       " + days + " in " + age + "
year " + "and" + month+ "months");
        }

PROGRAM 17: Modulus / Absolute

static void Main(string[] args)
        {
            // Finding Absoulute Value or Modulus
            int modulus_no;

             Console.WriteLine("Enter No Which u want to want to find out modulus");
             modulus_no = int.Parse(Console.ReadLine());

             Console.WriteLine(Math.Abs(modulus_no));

             Console.ReadKey();
         }

PROGRAM 18: Largest Number

{
             //Finding Greater Number B/w Three Number's
             int n1, n2, n3;

             Console.WriteLine("Enter 1st Number: ");
             n1 = int.Parse(Console.ReadLine());
             Console.WriteLine("Enter 2nd Number: ");
             n2 = int.Parse(Console.ReadLine());
             Console.WriteLine("Enter 3rd Number: ");
             n3 = int.Parse(Console.ReadLine());

             if (n1 > n2 && n1 > n3)
                  Console.WriteLine("n{0} is greater than {1} & {2}", n1, n2, n3);
             else
                  if (n2 > n3 && n2 > n1)
                       Console.WriteLine("n{0} is greater than {1} & {2}", n2, n1, n3);
                  else
                       if (n3 > n1 && n3 > n2)
                            Console.WriteLine("n{0} is greater than {1} & {2}", n3, n2, n1);
                       else
                            Console.WriteLine("Number's Are Equals");
             Console.ReadKey();
         }




         Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 18: Book Shop

       {
            int choice,engchoice,pchoice,dchoice;
            Console.WriteLine("Welcome In Liberty Books Pvt Ltd. nnn Please Enter Which Subject Book You
Want To Buy nnn1. English n2. Programming n3. Data Basen");
            Console.WriteLine("Enter Choice B/w 1-3");
            choice = Convert.ToInt32(Console.ReadLine());

            if (choice == 1)
            {
                Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. English By
Michel John n2. English By Oxfor Printing Press n3. English Dictonary hn");
                Console.WriteLine("Enter B/w 1-3");
                engchoice = Convert.ToInt32(Console.ReadLine());
                if (engchoice == 1)
                {
                    Console.WriteLine("English By Michel John price is $ 45"); Console.ReadKey();
                }
                if (engchoice == 2)
                {
       Console.WriteLine("English By Oxfor Printing Press price is $ 55"):    Console.ReadKey();
                }
                if(engchoice==3)
                {
                    Console.WriteLine("English Dictonary Price is $ 10"); Console.ReadKey();
                }
                else                    Console.WriteLine("Invalid Range"); Console.ReadKey();
            }
            if(choice==2)
{
Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. C Programming n2. C#
Programming n3. Java n"); Console.WriteLine("Enter B/w 1-3");
                pchoice = Convert.ToInt32(Console.ReadLine());
                if (pchoice == 1)
                {
        Console.WriteLine("C Programming Book price is $ 45");    Console.ReadKey();
                }
                if (pchoice == 2)
                {
      Console.WriteLine("C# Programming Book Press price is $ 55"); Console.ReadKey();
                }
                if(pchoice==3)
                {
                    Console.WriteLine("Java Programming Book Price is $ 10");      Console.ReadKey();
                }
                else            Console.WriteLine("Invalid Range");
            }
            if (choice == 3)
            {
                Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. Basic Data Base
n2. Oracle 10g n3. My Bank DataBase n");
                Console.WriteLine("Enter B/w 1-3");
                dchoice = Convert.ToInt32(Console.ReadLine());
                if (dchoice == 1)
                {
                    Console.WriteLine("Basic Database Book price is $ 45"); Console.ReadKey();
                }
                if (dchoice == 2)
                {
       Console.WriteLine("Oracle 10.G Book Press price is $ 55"); Console.ReadKey();
                }
                if (dchoice == 3)
                {
                    Console.WriteLine("My Bank Database Book Price is $ 10");    Console.ReadKey();
                }
                else                   Console.WriteLine("Invalid Range");}
                        else            { Console.WriteLine("Invalid Range"); }
            Console.WriteLine("nn This Program is Write By: Yasir Ahmed Khan");
           Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
}




PROGRAM 19: Area Of Square

{

int width,height,area;

Console.WriteLine("Enter Width:");
width = Int.Parse(Console.ReadLine());

Console.WriteLine("Enter Height:");
height = Int.Parse(Console.ReadLine());

area = width * height;

Console.WriteLine("Area of Square is "+area);
}

PROGRAM 20: (Area Of Circumference)

{

double radius,area;

Console.WriteLine("Enter Radius:");
radius = Double.Parse(Console.ReadLine());

area = radius * 3.14;

Console.WriteLine("Area of circumference                  is "+area);
}



PROGRAM 21: (Alpha , Beta , Theta )

    static void Main(string[] args)
    {
      Double theta;
      Console.WriteLine("give any angle to fint its value");
      theta=Convert.ToInt32(Console.ReadLine());
      {
         Console.WriteLine("Sine of " + theta + " is " +
         Math.Sin(theta));
         Console.WriteLine("Cosine of " + theta + " is " +
         Math.Cos(theta));
         Console.WriteLine("Tangent of " + theta + " is " +
         Math.Tan(theta));
         Console.WriteLine();
      }



PROGRAM 22: (Table With Start and Ending Point )

static void Main(string[] args)
        {
            Console.WriteLine("give table no: which you want");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("give starting point of table");
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine("give ending point of table");
            int c = int.Parse(Console.ReadLine());
            for (int d = a; d <= c; d++)
                Console.WriteLine(a + "*" + d + "="+(a * d))               }
           Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 23: (Sun to Earth Distance )

static void Main(string[] args)

     {

long inches;

long miles;

miles = 93000000; // 93,000,000 miles to the sun

// 5,280 feet in a mile, 12 inches in a foot.

inches = miles * 5280 * 12;

Console.WriteLine("Distance to the sun: " +

inches + " inches.");

}



PROGRAM 24: (Even or Odd Locator )

static void Main(string[] args)

    {

         int a;

         Console.WriteLine("Give a no: to find that either it is even or odd");

         a = int.Parse(Console.ReadLine());

         if (a % 2 == 0)

           Console.WriteLine(a + "no is even");

         else

           Console.WriteLine(a + "no:is odd");

    }

PROGRAM 25: (Prime Number )

static void Main(string[] args)

    {

         int a;

         Console.WriteLine("Give a no: to find either it is prime or not");

         a = int.Parse(Console.ReadLine());

         if (a % 2 == 1)

           Console.WriteLine("no: is prime");

         else

           Console.WriteLine("no: is not prime");

            }




                Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 26: (Discount Program)

static void Main(string[] args)

    {

        int price,quantity;

        double discount;

        double amounttobepaid;

        Console.WriteLine("enter the price of the shoes");

        price=int.Parse(Console.ReadLine());

        Console.WriteLine("enter the quantity of pair of the shoes");

        quantity = int.Parse(Console.ReadLine());

        Console.WriteLine("enter the discount percentage");

        discount = int.Parse(Console.ReadLine());

        amounttobepaid = price - ((discount/100*price))*quantity;

        Console.WriteLine("the price of shoes after deduction of discount is" + amounttobepaid);

    }



PROGRAM 27: (square of a number using method)

   static void Main(string[] args)
         {
             square(5);
         }
         public static void square(int a)
         {
             Console.WriteLine( a*a);
         }



PROGRAM 28: (Even Number Series using method)

static void Main(string[] args)
        {
            evennumber(2, 20);   // Starts From 2 , Ends at 20
        }
        public static void evennumber(int a,int b)
        {
            for (int x = a; x <= b; x= x+ 2)
                Console.Write(x + ",");
        }



PROGRAM 29: (QUEST NAWABSHAH)

static void Main(string[] args)
        {
            char [] quest = {'Q','U','E','S','T','N','A','W','A','B','S','H','A','H'};

                   for (int a = 0; a < 13; a++)
                       Console.Write(quest[a]);
             }


             Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
PROGRAM 30: (Pakistan)

static void Main(string[] args)
        {
            char[] quest = { 'P', 'a', 'k', 'i', 's', 't', 'a', 'n'};

               for (int a = 0; a < 7; a++)
                   Console.Write(quest[a]);
          }

PROGRAM 31: (1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17)
static void Main(string[] args)
        {
              // 1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17

               int a = 1, b = 1;
               do
               {
                   Console.Write(" "+a + "/" + b);
                   a++; b= b+ 2;
               }

               while (a < 10 && b < 18);
          }

PROGRAM 32: (Swapping of Number)

               int a, b;

               Console.Write("Enter Number For a");
               a = Int32.Parse(Console.ReadLine());
               Console.Write("Enter Number For b");
               b = Int32.Parse(Console.ReadLine());

               Console.Write("Value of A before Swaping" + a);
               Console.Write("nValue of B before Swaping" + b);

               b = (a + b) - (a = b);

               Console.Write("nnValue of A After Swaping" + a);
               Console.Write("nValue of B After Swaping" + b);



PROGRAM 33: (Leap year)

static void Main(string[] args)
        {

               int year;
               Console.Write("Enter a year to check if it is a leap year");
               year = Int32.Parse(Console.ReadLine());

               if (year % 400 == 0)
                    Console.Write(year + "is    a leap Year");
               else if (year % 100 == 0)
                    Console.Write(year + "is    not a leap Year");
               else if (year % 4 == 0)
                    Console.Write(year + "is    a leap Year");
               else
                    Console.Write(year + "is    not a leap Year");
          }



PROGRAM 34: (Factorial)

int a,n,fact=1;
        Console.Write("Enter A Number to Calculate its Factorial ");
        n=Int32.Parse(Console.ReadLine());
        for (a = 1; a <= n; a++)
            fact = fact * a;

          Console.WriteLine("Factorial of " + n + " is " + fact);




         Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014

More Related Content

What's hot

Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diplomamustkeem khan
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14Matthieu Garrigues
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diplomamustkeem khan
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)mehul patel
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)Karan Bora
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a BossBob Tiernay
 

What's hot (19)

Java Practical File Diploma
Java Practical File DiplomaJava Practical File Diploma
Java Practical File Diploma
 
C++ file
C++ fileC++ file
C++ file
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Java practical
Java practicalJava practical
Java practical
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
delegates
delegatesdelegates
delegates
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)CBSE Computer Project for Class 12 ( C++)
CBSE Computer Project for Class 12 ( C++)
 
C programs
C programsC programs
C programs
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
jq: JSON - Like a Boss
jq: JSON - Like a Bossjq: JSON - Like a Boss
jq: JSON - Like a Boss
 

Similar to C# console programms

Console programms
Console programmsConsole programms
Console programmsYasir Khan
 
Mpesa_C# (2)
Mpesa_C# (2)Mpesa_C# (2)
Mpesa_C# (2)Soud Fosi
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docxMehwishKanwal14
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannualAbhishek Pathak
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdfC# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdfssuserc77a341
 
Kumpulan contoh-program-pascal
Kumpulan contoh-program-pascalKumpulan contoh-program-pascal
Kumpulan contoh-program-pascalrey25
 

Similar to C# console programms (20)

Console programms
Console programmsConsole programms
Console programms
 
C#.net
C#.netC#.net
C#.net
 
Mpesa_C# (2)
Mpesa_C# (2)Mpesa_C# (2)
Mpesa_C# (2)
 
Loops (1)
Loops (1)Loops (1)
Loops (1)
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
C lab
C labC lab
C lab
 
C Programming
C ProgrammingC Programming
C Programming
 
Vb.net programs
Vb.net programsVb.net programs
Vb.net programs
 
C# console applications.docx
C# console applications.docxC# console applications.docx
C# console applications.docx
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannual
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdfC# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
 
Kumpulan contoh-program-pascal
Kumpulan contoh-program-pascalKumpulan contoh-program-pascal
Kumpulan contoh-program-pascal
 

More from Yasir Khan (20)

Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lec#1
Lec#1Lec#1
Lec#1
 
Ch10 (1)
Ch10 (1)Ch10 (1)
Ch10 (1)
 
Ch09
Ch09Ch09
Ch09
 
Ch05
Ch05Ch05
Ch05
 
Snooping protocols 3
Snooping protocols 3Snooping protocols 3
Snooping protocols 3
 
Snooping 2
Snooping 2Snooping 2
Snooping 2
 
Introduction 1
Introduction 1Introduction 1
Introduction 1
 
Hpc sys
Hpc sysHpc sys
Hpc sys
 
Hpc 6 7
Hpc 6 7Hpc 6 7
Hpc 6 7
 
Hpc 4 5
Hpc 4 5Hpc 4 5
Hpc 4 5
 
Hpc 3
Hpc 3Hpc 3
Hpc 3
 
Hpc 2
Hpc 2Hpc 2
Hpc 2
 
Hpc 1
Hpc 1Hpc 1
Hpc 1
 
Flynns classification
Flynns classificationFlynns classification
Flynns classification
 
Dir based imp_5
Dir based imp_5Dir based imp_5
Dir based imp_5
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

C# console programms

  • 1. CONSOLE PROGRAMS By: Yasir A k PROGRAM 01: (Print Name) static void Main(string[] args) { Console.WriteLine("Welcome"); //Console is a built-in class that contains the methods for displaying messages on the // screen and getting input from the keyboard. string name; Console.Write("Enter Your Name: "); name = Console.ReadLine(); // Input Console.WriteLine("Your Name Is: " + name); Console.ReadKey(); // to hold output like getch() } PROGRAM 02: (Print Integer) static void Main(string[] args) { int myInteger; string myString; myInteger = 17; myString = ""My Integer" is"; Console.WriteLine(myString +" "+ myInteger); Console.ReadKey(); } PROGRAM 03: (Addition, Subtraction, Multiplication and Division of a Number) static void Main(string[] args) { double firstNumber, secondNumber; string userName; Console.WriteLine("Enter your Name: "); userName = Console.ReadLine(); Console.WriteLine("Welcome "+ userName); Console.WriteLine("Now give me a number:"); firstNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Now give me another number:"); secondNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber + secondNumber); Console.WriteLine("The result of subtracting {0} from {1} is {2}.", secondNumber, firstNumber, firstNumber - secondNumber); Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber, secondNumber, firstNumber * secondNumber); Console.WriteLine("The result of dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber / secondNumber); Console.WriteLine("The remainder after dividing {0} by {1} is {2}.", firstNumber, secondNumber, firstNumber % secondNumber); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 2. PROGRAM 04: (Marks Sheet) static void Main(string[] args) { int phy, maths,eng,cp,isl; int total; double per; Console.WriteLine("nttt MARKS CERTIFICATE "); Console.Write("nEnter Physics Marks:"); phy = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Mathematics Marks:"); maths = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter English Marks: "); eng = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Programming Marks:"); cp = Convert.ToInt32(Console.ReadLine()); Console.Write("nEnter Islamiat Marks:"); isl = Convert.ToInt32(Console.ReadLine()); total = phy + maths+ isl + cp +eng; per = (total * 100) / 550; Console.WriteLine("Total is: "+Convert.ToInt32(total)); Console.WriteLine("Percentage is: {0} %" , Convert.ToDouble(per)); Console.WriteLine("n"); if (per > 80.0) Console.WriteLine("You Got Grade: A1 "); else if (per > 70.0) Console.WriteLine("You Got Grade: A"); else if (per > 60.0) Console.WriteLine("You Got Grade: B"); else if (per > 50.0) Console.WriteLine("You Got Grade: C"); else if (per < 49.9) Console.WriteLine("Your Fail"); Console.WriteLine("nnttThis Software is Developed By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 05: Table using For Loop static void Main(string[] args) { int tab_no; Console.WriteLine("ntttTable Generatorn"); Console.Write("Enter Table No: "); tab_no = Convert.ToInt32(Console.ReadLine()); for(int x=1; x<=10;x++) { Console.WriteLine("n{0} * {1} = {2}",tab_no,x,(tab_no*x) ); } Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 3. PROGRAM 06: Sum of Two Number’s { int number1, number2, sum; Console.Write("Enter First No:"); number1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter Second No:"); number2 = Convert.ToInt32(Console.ReadLine()); sum = number1 + number2; Console.Write("Sum is " + sum); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 07: Cities Temperature { double nshah, khi, hyd, multan, isd, lahore, average; Console.WriteLine("nnttt AVERAGE TEMPERATURE"); Console.Write("nEnter Temperature of Nawabshah City :"); nshah = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Hyderabad City :"); hyd = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Multan City :"); multan = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Islamabad City :"); isd = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Lahore City :"); lahore = Convert.ToDouble(Console.ReadLine()); Console.Write("nEnter Temperature of Karachi City :"); khi = Convert.ToDouble(Console.ReadLine()); average = (nshah + hyd + multan + isd + lahore) / 6; Console.WriteLine("nnAVERAGE TEMPERATURE IS: " + average); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 08: Square & Cube of a Number { int num,square,cube,sq_root; Console.Write("Enter Number: "); num = Convert.ToInt32(Console.ReadLine()); square = num * num; cube = square * num; Console.WriteLine("nn Square is " + square); Console.WriteLine("nn Cube is " + cube); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 4. PROGRAM 09: Number Compression { int num1, num2; Console.Write("nntt COMPARISSION B/W TWO NUMBER's"); Console.Write("nnEnter Ist Number "); num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter IInd Number "); num2 = Convert.ToInt32(Console.ReadLine()); if (num1 == num2) Console.WriteLine(num1+" is Equals to "+num2); if(num1>num2) Console.WriteLine(num1 + " is Greater Than " + num2); if (num1 < num2) Console.WriteLine(num1 + " is Less Than " + num2); if (num1 != num2) Console.WriteLine(num1 + " is Not Equals to " + num2); if (num1 >= num2) Console.WriteLine(num1 + " is Greater Than or equals to " + num2); if (num1 <= num2) Console.WriteLine(num1 + " is Less Than or equals to " + num2); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 10: Kilo Meter to meter { int meter, km; Console.Write("nntt Enter Value in Kilo Meter "); km = Convert.ToInt32(Console.ReadLine()); meter = km * 1000 ; Console.Write("nntt The Value in Meter Is " + meter); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 5. PROGRAM 11: Age Analyzer { int year, month,day; Console.Write("nntt Enter The Age in Year "); year = Convert.ToInt32(Console.ReadLine()); Console.Write("nntt Enter The Age in MOnth "); month = Convert.ToInt32(Console.ReadLine()); day = year * 365 + month *30 ; Console.Write("nntt Your " + day + " days old"); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 12: KB to Byte Conversion { int bit,kb; Console.Write("nntt Enter The Data Size in Kilo Bytes "); kb = Convert.ToInt32(Console.ReadLine()); bit = kb * 1024 ; Console.Write("nntt Your Data Size is " + bit + " Byte "); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 13: Temperature Conversion static void Main(string[] args) { //Temperature of a city in Fahrenheit degrees is input through the keyboard. //Write a program to convert this temperature into Centigrade degrees. double temp_f, temp_c; Console.WriteLine("Enter Your City Temperature: "); temp_f = double.Parse(Console.ReadLine()); temp_c = (temp_f - 32) * 5 / 9; Console.WriteLine("Temperature in Celsius is : " + temp_c); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 6. PROGRAM 14: Conversion of Length static void Main(string[] args) { //The distance between two cities (in km.) is input through the keyboard. //Write a program to convert and print this distance in meters, feet, inches and centimeters. double km, m, feet, inches, centimeter; Console.Write("Enter Distance B/w Two Cities in Kilo Meter: "); km = double.Parse(Console.ReadLine()); m = km * 1000; feet = m * 3.28084; centimeter = m * 100; inches = m * 39.37008; Console.WriteLine("Distance in Km : " + km); Console.WriteLine("Distance in m : " + m); Console.WriteLine("Distance in feet : " + feet); Console.WriteLine("Distance in centimeter : " + centimeter); Console.WriteLine("Distance in inches : " + inches); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } PROGRAM 15: Salary Sheet static void Main(string[] args) { //Ramesh’s basic salary is input through the keyboard. //His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. //Write a program to calculate his gross salary. int basic_salary; double dearnesss_allowance, house_rent_allowance, gross_salary; Console.Write("nn ttPlease Enter Your Basic Salary: "); basic_salary = int.Parse(Console.ReadLine()); dearnesss_allowance = (basic_salary * 0.4); house_rent_allowance= (basic_salary * 0.2); gross_salary = dearnesss_allowance + house_rent_allowance + basic_salary; Console.WriteLine("n ttBasic Salary: " + basic_salary); Console.WriteLine("n ttDearness Allowance: " + dearnesss_allowance); Console.WriteLine("n ttHouse Rent Allowance: " + house_rent_allowance); Console.WriteLine("n ttGross Salary: " + gross_salary); Console.WriteLine("nnttt This Program is Written By: Yasir Ahmed Khan"); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 7. PROGRAM 16: Age Analyzer static void Main(string[] args) { int age, days, month; Console.WriteLine("give your age progarme will convert it into days"); Console.WriteLine("give your age in years"); age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("give your age in months"); month = Convert.ToInt32(Console.ReadLine()); days = age * 365 + month * 30; Console.WriteLine("conversion successful,the days will be " + days + " in " + age + " year " + "and" + month+ "months"); } PROGRAM 17: Modulus / Absolute static void Main(string[] args) { // Finding Absoulute Value or Modulus int modulus_no; Console.WriteLine("Enter No Which u want to want to find out modulus"); modulus_no = int.Parse(Console.ReadLine()); Console.WriteLine(Math.Abs(modulus_no)); Console.ReadKey(); } PROGRAM 18: Largest Number { //Finding Greater Number B/w Three Number's int n1, n2, n3; Console.WriteLine("Enter 1st Number: "); n1 = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 2nd Number: "); n2 = int.Parse(Console.ReadLine()); Console.WriteLine("Enter 3rd Number: "); n3 = int.Parse(Console.ReadLine()); if (n1 > n2 && n1 > n3) Console.WriteLine("n{0} is greater than {1} & {2}", n1, n2, n3); else if (n2 > n3 && n2 > n1) Console.WriteLine("n{0} is greater than {1} & {2}", n2, n1, n3); else if (n3 > n1 && n3 > n2) Console.WriteLine("n{0} is greater than {1} & {2}", n3, n2, n1); else Console.WriteLine("Number's Are Equals"); Console.ReadKey(); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 8. PROGRAM 18: Book Shop { int choice,engchoice,pchoice,dchoice; Console.WriteLine("Welcome In Liberty Books Pvt Ltd. nnn Please Enter Which Subject Book You Want To Buy nnn1. English n2. Programming n3. Data Basen"); Console.WriteLine("Enter Choice B/w 1-3"); choice = Convert.ToInt32(Console.ReadLine()); if (choice == 1) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. English By Michel John n2. English By Oxfor Printing Press n3. English Dictonary hn"); Console.WriteLine("Enter B/w 1-3"); engchoice = Convert.ToInt32(Console.ReadLine()); if (engchoice == 1) { Console.WriteLine("English By Michel John price is $ 45"); Console.ReadKey(); } if (engchoice == 2) { Console.WriteLine("English By Oxfor Printing Press price is $ 55"): Console.ReadKey(); } if(engchoice==3) { Console.WriteLine("English Dictonary Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range"); Console.ReadKey(); } if(choice==2) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. C Programming n2. C# Programming n3. Java n"); Console.WriteLine("Enter B/w 1-3"); pchoice = Convert.ToInt32(Console.ReadLine()); if (pchoice == 1) { Console.WriteLine("C Programming Book price is $ 45"); Console.ReadKey(); } if (pchoice == 2) { Console.WriteLine("C# Programming Book Press price is $ 55"); Console.ReadKey(); } if(pchoice==3) { Console.WriteLine("Java Programming Book Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range"); } if (choice == 3) { Console.WriteLine("Now , n Please Enter Which Book You Want To Buy nnn1. Basic Data Base n2. Oracle 10g n3. My Bank DataBase n"); Console.WriteLine("Enter B/w 1-3"); dchoice = Convert.ToInt32(Console.ReadLine()); if (dchoice == 1) { Console.WriteLine("Basic Database Book price is $ 45"); Console.ReadKey(); } if (dchoice == 2) { Console.WriteLine("Oracle 10.G Book Press price is $ 55"); Console.ReadKey(); } if (dchoice == 3) { Console.WriteLine("My Bank Database Book Price is $ 10"); Console.ReadKey(); } else Console.WriteLine("Invalid Range");} else { Console.WriteLine("Invalid Range"); } Console.WriteLine("nn This Program is Write By: Yasir Ahmed Khan"); Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 9. } PROGRAM 19: Area Of Square { int width,height,area; Console.WriteLine("Enter Width:"); width = Int.Parse(Console.ReadLine()); Console.WriteLine("Enter Height:"); height = Int.Parse(Console.ReadLine()); area = width * height; Console.WriteLine("Area of Square is "+area); } PROGRAM 20: (Area Of Circumference) { double radius,area; Console.WriteLine("Enter Radius:"); radius = Double.Parse(Console.ReadLine()); area = radius * 3.14; Console.WriteLine("Area of circumference is "+area); } PROGRAM 21: (Alpha , Beta , Theta ) static void Main(string[] args) { Double theta; Console.WriteLine("give any angle to fint its value"); theta=Convert.ToInt32(Console.ReadLine()); { Console.WriteLine("Sine of " + theta + " is " + Math.Sin(theta)); Console.WriteLine("Cosine of " + theta + " is " + Math.Cos(theta)); Console.WriteLine("Tangent of " + theta + " is " + Math.Tan(theta)); Console.WriteLine(); } PROGRAM 22: (Table With Start and Ending Point ) static void Main(string[] args) { Console.WriteLine("give table no: which you want"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("give starting point of table"); int b = int.Parse(Console.ReadLine()); Console.WriteLine("give ending point of table"); int c = int.Parse(Console.ReadLine()); for (int d = a; d <= c; d++) Console.WriteLine(a + "*" + d + "="+(a * d)) } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 10. PROGRAM 23: (Sun to Earth Distance ) static void Main(string[] args) { long inches; long miles; miles = 93000000; // 93,000,000 miles to the sun // 5,280 feet in a mile, 12 inches in a foot. inches = miles * 5280 * 12; Console.WriteLine("Distance to the sun: " + inches + " inches."); } PROGRAM 24: (Even or Odd Locator ) static void Main(string[] args) { int a; Console.WriteLine("Give a no: to find that either it is even or odd"); a = int.Parse(Console.ReadLine()); if (a % 2 == 0) Console.WriteLine(a + "no is even"); else Console.WriteLine(a + "no:is odd"); } PROGRAM 25: (Prime Number ) static void Main(string[] args) { int a; Console.WriteLine("Give a no: to find either it is prime or not"); a = int.Parse(Console.ReadLine()); if (a % 2 == 1) Console.WriteLine("no: is prime"); else Console.WriteLine("no: is not prime"); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 11. PROGRAM 26: (Discount Program) static void Main(string[] args) { int price,quantity; double discount; double amounttobepaid; Console.WriteLine("enter the price of the shoes"); price=int.Parse(Console.ReadLine()); Console.WriteLine("enter the quantity of pair of the shoes"); quantity = int.Parse(Console.ReadLine()); Console.WriteLine("enter the discount percentage"); discount = int.Parse(Console.ReadLine()); amounttobepaid = price - ((discount/100*price))*quantity; Console.WriteLine("the price of shoes after deduction of discount is" + amounttobepaid); } PROGRAM 27: (square of a number using method) static void Main(string[] args) { square(5); } public static void square(int a) { Console.WriteLine( a*a); } PROGRAM 28: (Even Number Series using method) static void Main(string[] args) { evennumber(2, 20); // Starts From 2 , Ends at 20 } public static void evennumber(int a,int b) { for (int x = a; x <= b; x= x+ 2) Console.Write(x + ","); } PROGRAM 29: (QUEST NAWABSHAH) static void Main(string[] args) { char [] quest = {'Q','U','E','S','T','N','A','W','A','B','S','H','A','H'}; for (int a = 0; a < 13; a++) Console.Write(quest[a]); } Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014
  • 12. PROGRAM 30: (Pakistan) static void Main(string[] args) { char[] quest = { 'P', 'a', 'k', 'i', 's', 't', 'a', 'n'}; for (int a = 0; a < 7; a++) Console.Write(quest[a]); } PROGRAM 31: (1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17) static void Main(string[] args) { // 1/1, 2/3, 3/5. 4/7. 5/9, 6/11, 7/13, 8/15, 9/17 int a = 1, b = 1; do { Console.Write(" "+a + "/" + b); a++; b= b+ 2; } while (a < 10 && b < 18); } PROGRAM 32: (Swapping of Number) int a, b; Console.Write("Enter Number For a"); a = Int32.Parse(Console.ReadLine()); Console.Write("Enter Number For b"); b = Int32.Parse(Console.ReadLine()); Console.Write("Value of A before Swaping" + a); Console.Write("nValue of B before Swaping" + b); b = (a + b) - (a = b); Console.Write("nnValue of A After Swaping" + a); Console.Write("nValue of B After Swaping" + b); PROGRAM 33: (Leap year) static void Main(string[] args) { int year; Console.Write("Enter a year to check if it is a leap year"); year = Int32.Parse(Console.ReadLine()); if (year % 400 == 0) Console.Write(year + "is a leap Year"); else if (year % 100 == 0) Console.Write(year + "is not a leap Year"); else if (year % 4 == 0) Console.Write(year + "is a leap Year"); else Console.Write(year + "is not a leap Year"); } PROGRAM 34: (Factorial) int a,n,fact=1; Console.Write("Enter A Number to Calculate its Factorial "); n=Int32.Parse(Console.ReadLine()); for (a = 1; a <= n; a++) fact = fact * a; Console.WriteLine("Factorial of " + n + " is " + fact); Programs Are Compiled By: Yasir Ahmed Khan | yasirahmedkhan@ymail.com | 03337015014