using System;
class HelloWorld
{
static void Main ()
{
string[][]student_detail = new string[2][];
for (int i = 0; i < student_detail.Length; i++)
{
student_detail[i] = new string[6];
//Console.WriteLine('student '+student_detail[i].GetLength(0));
}
for (int i = 0; i < student_detail.Length; i++)
{
Console.WriteLine ('Enter ' + (i + 1) + ' student roll no :');
student_detail[i][0] = Console.ReadLine ();
for (int j = 1; j < student_detail[i].GetLength (0); j++)
{
Console.WriteLine ('Enter ' + j + ' marks of ' + (i + 1) +
' student :');
student_detail[i][j] = Console.ReadLine ();
}
}
Console.WriteLine ('Roll No \t Marks \n');
for (int i = 0; i < student_detail.Length; i++)
{
Console.Write (student_detail[i][0] + '\t');
for (int j = 1; j < student_detail[i].GetLength (0); j++)
{
Console.Write (student_detail[i][j] + ' ');
}
Console.WriteLine ('');
}
Console.WriteLine('If you want to search marks of student then press for yes = 'y' or no = 'n' ');
string yes_no = Console.ReadLine ();
while (yes_no.Equals ('y'))
{
bool exist_val=false;
Console.WriteLine('Enter student rollno :');
string search = Console.ReadLine ();
for (int i = 0; i < student_detail.Length; i++)
{
if(search.Equals(student_detail[i][0]))
{
Console.Write ('\tMarks \t');
for (int j = 1; j < student_detail[i].GetLength (0); j++)
{
Console.Write (student_detail[i][j] + ' ');
}
Console.WriteLine ('');
exist_val=true;
break;
}else{
exist_val=false;
}
}
if(!exist_val)
Console.WriteLine('this student roll no doesn't exits ..... ');
Console.WriteLine('If you want to search marks of student then press for yes = 'y' or no = 'n' ');
yes_no = Console.ReadLine ();
}
Console.WriteLine ('\n\nThanks for using....');
}
}
Output -
Enter 1 student roll no :
123
Enter 1 marks of 1 student :
45
Enter 2 marks of 1 student :
56
Enter 3 marks of 1 student :
58
Enter 4 marks of 1 student :
75
Enter 5 marks of 1 student :
59
Enter 2 student roll no :
124
Enter 1 marks of 2 student :
45
Enter 2 marks of 2 student :
78
Enter 3 marks of 2 student :
95
Enter 4 marks of 2 student :
[6n56
Enter 5 marks of 2 student :
78
Roll No Marks
123 45 56 58 75 59
124 45 78 95 56 78
If you want to search marks of student then press for yes = 'y' or no = 'n'
y
Enter student rollno :
125
this student roll no doesn't exits .....
If you want to search marks of student then press for yes = 'y' or no = 'n'
y
Enter student rollno :
123
Marks 45 56 58 75 59
If you want to search marks of student then press for yes = 'y' or no = 'n'
y
Enter student rollno :
124
Marks 45 78 95 56 78
If you want to search marks of student then press for yes = 'y' or no = 'n'
y
Enter student rollno :
125
this student roll no doesn't exits .....
If you want to search marks of student then press for yes = 'y' or no = 'n'
n
Thanks for using....
Leave Comment