0% found this document useful (0 votes)
6 views15 pages

Lab 06

The document contains C# code that prompts the user for input to perform various tasks, including generating Fibonacci numbers, calculating grades based on marks, collecting employee details, and printing patterns of asterisks. It includes loops for user input and conditional statements for grade determination. The code demonstrates basic programming concepts such as loops, conditionals, and data types in C#.

Uploaded by

whatnow.055
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

Lab 06

The document contains C# code that prompts the user for input to perform various tasks, including generating Fibonacci numbers, calculating grades based on marks, collecting employee details, and printing patterns of asterisks. It includes loops for user input and conditional statements for grade determination. The code demonstrates basic programming concepts such as loops, conditionals, and data types in C#.

Uploaded by

whatnow.055
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Console.

WriteLine("Enter the value of N");


int n = Convert.ToInt32(Console.ReadLine());
int last = 1, secondlast = 0;
Console.Write("{0} , {1}, ", secondlast, last);
int next;
for (int i = 1; i <=n-2; i++)
{
next = secondlast + last;
Console.WriteLine("{0}, {1},", next);
secondlast = last;
last = next;
Console.Write("{0} , {1}, ", secondlast, last);

}
Console.WriteLine("Enter the value of N");
int n = Convert.ToInt32(Console.ReadLine());
int last = 1, secondlast = 0;
Console.Write("{0} , {1}, ", secondlast, last);
int next;
for (int i = 1; i <=n-2; i++)
{
next = secondlast + last;
Console.WriteLine("{0}, {1},", next);
secondlast = last;
last = next;
Console.Write("{0} , {1}, ", last, next);

Console.WriteLine("Please enter number of subjects: ");


int sub = Convert.ToInt32(Console.ReadLine());
double obtmarks = 0;
for (int i = 1; i <= sub; i ++)
{
Console.WriteLine("Please enter {0} subject's marks: ", i);
double marks = Convert.ToDouble(Console.ReadLine());
obtmarks += marks;

}
int totmarks = 100 * sub;
double percentage = obtmarks / totmarks * 100;
if (percentage >= 90 && percentage < 100)
{
Console.WriteLine(" The grade is A");
}
else if (percentage >= 80 && percentage < 90)
{
Console.WriteLine(" The grade is B");
}
else if (percentage >= 70 && percentage < 80)
{
Console.WriteLine(" The grade is C");
}
else if (percentage >= 60 && percentage < 70)
{
Console.WriteLine(" The grade is D");
}
else if (percentage >= 50 && percentage < 60)
{
Console.WriteLine(" The grade is E");
}
else if (percentage >= 40 && percentage > 0)
{
Console.WriteLine(" The grade is F");
}
Console.WriteLine("Please enter number of employees: ");
int num = Convert.ToInt32(Console.ReadLine());

for (int i = 1; i <= num; i ++)


{

Console.WriteLine("Please enter {0} Employee's name: ", i);


string name = Console.ReadLine();
Console.WriteLine("Please enter {0} Employee's CNIC ", i);
double nic = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter {0} Employee's Sallary ", i);
double sal = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("Employee {0}'s name is {1}, CNIC is {2} and Sallary is {3}", i, name, nic,
sal);
}

for (int i = 1; i <= 4; i ++)


{
for (int j = 1; j <= i; j++)
{
Console.Write(" * ");
}

Console.WriteLine("");
}

for (int i = 4; i >= 1; i --)


{
for (int j = 1; j <= i; j++)
{
Console.Write(" * ");
}

Console.WriteLine("");

You might also like