.Net (Network Enable Technology) 99 days Program


         1st Day in NIIT

            1. The computer activities are broken into the following three phases:
Input Phase
Process Phase
Output Phase

2.      The cycle of activities performed by a computer follows the Input-Process-Output(I-P-O) cycle.
3.      A computer needs a set of instructions called a program to perform the I-P-O cycle.
4.      A programming language helps the computer understand the instructions. Instruction in a program can be-

Sequential
Decision-making
Iterative [refers to loop (for, while, do etc)]

5.      An electronic component can be either in an on state or an off state.
6.      Components are represented as a combination of on and off state.
7.      A high level programming language consists of a set of instructions. It is represented by using English word.
8.      Examples of high level language are C, C++, C# and Java.
9.      All programming languages have:

A vocabulary, which is a set of keywords of the programming language.
A grammar, which is referred to as the syntax.

10.  A compiler is a special program that converts the instructions into machine language.
11.  The compiler follows the I-P-O cycle:-

It takes the instructions as a input.
It processes the instructions and convert them to machine language.

12.  According to D.E.Knuth, an algorithm has the following characteristics:

An algorithm has a fixed number of steps.
Each step in an algorithm specifies the action to be perform.
The steps in an algorithm specify basic operation.
An algorithm accepts input data.
An algorithm generates one or more outputs after the input is processed.

13.  A flowchart is a graphical representation of an algorithm. It consists of a set of symbols.
14.  Each symbol represents a specific kind of activity depicted in the algorithm.
15.  The advantage of using flowchart are:-

It helps in analyzing the problem effectively.
It acts as a guide during the program development phase.
It helps easy debugging of logical errors.


16.  Disadvantages of  using flowchart are:

A lengthy flowchart may extend over multiple pages, which reduces readability.
Drawing a flowchart is time consuming.
The changes made to a single step may cause redrawing the entire flowchart.

17.  Application of C# are:

Control based application.
Windows based application.
Wed based application.

18.  Error in debugging:

Syntax error.
Logical error.

19.  Pseudo code:

Is a detailed yet easy description of what an algorithm must do.
Is written in a formally-styled English language.
Is used as an initial step in the process of developing programs.

20.  The advantage of using pseudo code are:-

It is easier and faster to write.
It does not need to be rewritten if any changes are made.
It can be converted to a program by using any programming language.

21.  Limitation of using pseudo code are:-

 It does not provide a graphical representation of an algorithm.
 It is difficult to read if there contains nested statement.


Begin
Numeric a, numeric b, numeric c
Accept a, accept b
Add a and add b and store the result in c
Display c
End


22.  Write an algorithm to accept two numbers, divided the first number by the second number, and display their quotient.

1.      Start the algorithm.
2.      Get the first number.
3.      Get the second number.
4.      Divide the first number by the second number.
5.      Display the quotient.
6.      End the algorithm.

2nd Day in NIIT
                                                                                                                                                                         

1.      Pseudocode is used to represent the logic of the solution to a problem.
2.      Once the pseudocode is verified, it can be converted into a program by using the:-

Vocabulary of a programming language.
Syntax of a programming language.

3.      The following table lists shows the keywords that are used to write a pseudocode.

//
It represents a comment entry.
begin….end
The steps of the pseudocode are written between the begin….end block.
accept
It is used to accept input.
compute
It is used to calculate the result of an expression.
display
It is used to display an output.
if….else
It is used when depending upon condition different actions may have to be taken.
repeat….until
This is an iterative construct with a testing statement at the bottom of the iterative set of the statements.
while
This is an iterative construct with a testing statement at the top of the iterative set of the statements
for ( ; ; )
This is an iterative construct in which a variable is initialized, incremented and an expression is tested in the same line.
call subroutine_name
It is used to invoke subroutines, subprograms, or a procedure that is specified by the subroutine_name

4.      A variable refers to the memory location that can store only one value at a time but can vary throughout the program execution.
5.      A constant refers to the memory location that holds a value, which fixed through the program execution.
6.      A user may enter any type of value, such as name, address, age and data.
7.      The value can be broadly categorized in the following types:

Numeric
Character

8.      Some convention that can be followed while naming variables are-

a)      The first letter of the variable may indicate the data type used. Example- cName, nAge.
b)      The variable name should clearly describe its purpose. Example- nScore is a numeric variable to store the score.
c)      The variable name should not contain any embedded space and symbols. Example-    ? ! @ # $ % & () {} [] : ; \ / should not be used.However, an underscore can be used wherever a space is required. nBasic_salary.
d)     The variable can assign values by using the following two methods:-
Direct assignment
Accept statement
9.      Values can be assigned to variables in the direct assignment method by using the equal to (=) sign or using the compute keyword:

Variable_name = value
Compute variable_name as value.

10.  Values can be assigned to variables by using the accept statement, as shown in the syntax:

Accept variable_name

                                                              C#



/* Write a program to print 1234
                            123
                            12
                            1     */
using System;
public class Pyramid
{
    public static void Main()
    {
        int i, j;
        for (i = 4; i >= 1; i--)
        {
            for (j = 1; j <= i; j++)
            {
                Console.Write(j);
            }


            Console.WriteLine("\n");
        }
    }
}
      


/* Write a program to print 1
                            12
                            123
                            1234     */
using System;              
public class Pyramid
{
    public static void Main()
    {
        int i, j;
        for (i = 1; i <=4; i++)
        {
            for (j = 1; j <=i; j++)
            {
                Console.Write(j);
            }

            Console.WriteLine("\n");
        }
    }
}
      


/* Write a program to print 1 2
                            3 4
                            5 6
                            7 8
                            9 10   */
using System;
public class Pyramid
{
    public static void Main()
    {
        int i;
        for (i = 1; i<=10; i=i+2)          
            {
                Console.WriteLine("{0}\t{1}",i,(i+1));
            }
         
     }
 }




\\ TextModeFileOrganization


using System;
using System.IO;

namespace TextModeFileOrganization
{
    class student
    {
        int rno;
        string name;
        int mat, phy, che, tot;
        float avg;
        string res, grade;
        public void Accept()
        {
            Console.Write("Enter the student roll no: ");
            rno = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter the student name: ");
            name = Console.ReadLine();
            Console.Write("Enter the mathematics no: ");
            mat = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter the physics no: ");
            phy = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter the chemistry no: ");
            che= Convert.ToInt32(Console.ReadLine());
        }
        public void SaveRecord()
        {
            tot = mat + phy + che;
            avg = tot / 2.7f;
            if (mat >= 60 && phy >= 30 && che >= 30)
            {
                res = "Pass";
                if(avg>=80)
                    grade="Distinction";
                        else if (avg>=60)
                            grade="First";
                          else if (avg>=50)
                                grade="Second";
                                else
                                    grade="Third";
            }
            else
            {
                res = "Fail";
                    grade="Not Applicable";
            }
            Console.WriteLine("Your Record is Saved");
            FileStream fs = new FileStream(@"h:\joon\Dushmanta.txt", FileMode.Append, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine("{0}   {1}   {2}   {3}   {4}   {5}   {6}   {7}   {8}", rno, name, mat, phy, che, tot, avg, res, grade);
            sw.Close();
            fs.Close();
        }
        public void Read1() //charecter by character
        {
            FileStream fs = new FileStream(@"h:\joon\Dushmanta.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            sr.BaseStream.Seek(0, SeekOrigin.Begin);
            int ch;
            while ((ch = sr.Read()) != 1)
            {
                Console.WriteLine(Convert.ToChar(ch));
            }
            sr.Close();
            fs.Close();
        }
        public void Read2() //line by line
        {
            FileStream fs = new FileStream(@"h:\joon\Dushmanta.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            sr.BaseStream.Seek(0, SeekOrigin.Begin);
            string str;
            Console.WriteLine("File Content:  ");
            Console.WriteLine("*******************************************");
            while ((str = sr.ReadLine()) != null)
            {
                Console.WriteLine(str);
            }
            sr.Close();
            fs.Close();
        }
        public void Read3() //entire file at a time
        {
            FileStream fs = new FileStream(@"h:\joon\Dushmanta.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            sr.BaseStream.Seek(0, SeekOrigin.Begin);
            string data = sr.ReadToEnd();
            sr.Close();
            fs.Close();
            Console.WriteLine("File Content:  ");
            Console.WriteLine("*******************************************");
        }
    }
    class Program
    {
        public static void Main(string[] args)
        {
            student std = new student();
 
        int choice;
        while(true)//infinite loop
          {
             Console.WriteLine("\t\t\t\t Main___Menu");
             Console.WriteLine("\t\t\t******************************");
             Console.WriteLine("\t\t\t1.Add New Student Details");
             Console.WriteLine("\t\t\t2.Read Data Charecter by Charecter");
             Console.WriteLine("\t\t\t3.Read Data Line by Line");
             Console.WriteLine("\t\t\t4.Read Entire File At A Time");
             Console.WriteLine("\t\t\t5.Exit");
             Console.WriteLine("\t\t Enter Your Choice: 1 to 5");
             choice = Convert.ToInt32(Console.ReadLine());
             switch (choice)
             {
                 case 1: std.Accept();
                     std.SaveRecord();
                     break;
                 case 2: std.Read1();
                     break;
                 case 3: std.Read2();
                     break;
                 case 4: std.Read3();
                     break;
                 case 5: return;
                 default: Console.WriteLine("Invalid Choice Entered.Try Again");
                     break;


             }
          }
       }
    }
}

\\ Operator Overloading

using System;
namespace Opover
{
class Test
{
int a;
public Test()
{
}
public Test(int p)
{
a=p;
}
public void Display()
{
Console.WriteLine("a value={0}",a);
}
public static Test operator ++ (Test t1)
{
Test temp=new Test();
temp.a=t1.a++;
return temp;
}
public static Test operator -- (Test t1)
{
Test temp=new Test();
temp.a=t1.a--;
return temp;
}
}
class MyEntry
{
public static void Main()
{
Test obj1=new Test(30);
Test obj2=new Test(10);
Test obj3=++obj1;
Test obj4=obj2--;
obj1.Display();
obj2.Display();
obj3.Display();
obj4.Display();
}
}
}