/*..................Printing student info ......................*/
using System;
class Student
{
//Member data.
string name;
string regno;
string add;
int age;
//Member function
void Accept()
{
Console.WriteLine("Enter the name:\t");
name=Console.ReadLine();
Console.WriteLine("Enter the regno:\t");
regno=Console.ReadLine();
Console.WriteLine("Enter the address:\t");
add=Console.ReadLine();
Console.WriteLine("Enter the age :\t");
age=Convert.ToInt32(Console.ReadLine());
}
void Display()
{
Console.WriteLine("The name of student is :{0}",name);
Console.WriteLine("The regno of student is :{0}",regno);
Console.WriteLine("The age of student is :{0}",age);
Console.WriteLine("The add of student is :{0}",add);
}
public static void Main(string [] arg)
{
Student S=new Student();
S.Accept();
S.Display();
}
}
/*...................Fibonacci series.................*/
using System;
class Fibonacci
{
int f[] =new int[15];
void Accept()
{
f[0]=0;
f[1]=1;
Console.WriteLine("Enter the num:\t");
int num=Convert.ToInt32(Console.ReadLine());
}
void Display()
{
for(int i=2;i<=num;i++)
{
f[i]=f[i-1]+f[i-2];
Console.WriteLine(f[i]);
}
}
}
class Result
{
public static void Main(string [] arg)
{
Fibonacci F=new Fibonacci();
F.Accept();
F.Display();
}
}
Labels: C# Programming