0% found this document useful (0 votes)
11 views11 pages

Practical 5 to 8

Uploaded by

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

Practical 5 to 8

Uploaded by

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

JAMIA MILLIA ISLAMIA

Practical file
Of
Visual Programming Lab
(DCO 612)

Diploma in Computer Engineering


(6th Semester)

Submitted by: Submitted to:


SHOAIB AKHTAR MOHD ARIF
Roll-18DCS063 Computer Engineering section
Semester-6th University Polytechnic, JMI
INDEX

S.NO PROGRAMS Date T. Sign.

Introduction to the Microsoft Visual Studio .NET 25/03/2021


programming environment, properties, methods and events.
1.

Introduction to C# programming language and write a 26/03/2021


program for the swapping of two numbers without using third
2. variable in console environment.
Introduction to Data types and write a program to create 27/03/2021
Employee details using console application.
3.

Introduction to Data types and write a program to create 28/03/2021


Employee details using console application.
4.

Write a program to design following pyramids using C# dot 04/04/2021


5. Net.

Write a program in C# dot Net to sort an Array of n elements. 04/04/2021


Also, show the number of swapping occurred in sorting
6. process.
Write a program to create list for n number of students using 05/04/2021
the concept of “List”.
7.
Write a program to search the name of students in an array 05/04/2021
using “For each loop”.
8.

9.

10.
Practical 5: - Write a program to design following pyramids using C# dot Net.

Pattern 1 :

using System;
namespace Pattern
{
class Program
{
static void Main(string[] args)
{
int numRows;
Console.WriteLine("Enter number of rows ");
numRows = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
for (int i = numRows; i >= 1; --i)
{
for (int j = 1; j <= i; ++j) {
Console.Write(j);
}
Console.WriteLine();
}
}
}
}
Output: -
Pattern 2:

using System;

namespace Pattern
{
class Program
{

static void Main(string[] args)


{
int numRows;
int a, b;
Console.WriteLine("Enter number of rows ");
numRows = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
for (a = 1; a <= numRows; a++)
{
for (b = 1; b <= numRows - a; b++)
{
Console.Write(" ");
}
for (b = 1; b <= a; b++)
{
Console.Write("* ");
}
Console.Write("\n");
}
Console.Read();

}
}
}
Output :-
Practical 6: - Write a program in C# dot Net to sort an Array of n elements. Also, show the
number of swapping occurred in sorting process.

using System;
namespace SortArray
{
class Program
{
static void Main(string[] args)
{
int[] myArr = new int[5] { 17, 79, 2, 43, 25 };
int i, j, temp;
int count = 0;
Console.WriteLine("Elements:\n ");
for (i = 0; i < 5; i++)
{
Console.Write("{0} ", myArr[i]);
}
for (i = 0; i < 5; i++)
{
for (j = i + 1; j < 5; j++)
{
if (myArr[i] > myArr[j])
{
temp = myArr[i];
myArr[i] = myArr[j];
myArr[j] = temp;
count++;
}
}
}

Console.WriteLine("\nSorting in Ascending order:\n");


for (i = 0; i < 5; i++)
{
Console.Write("{0} ", myArr[i]);
}
Console.Write("\n\n");
Console.WriteLine(" \nThe number of swapping occured is: " + count);

Console.Read();

}
}
}

Output: -
Practical 7: - Write a program to create list for n number of students using the concept of
“List”.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ListExample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number of student you want to add in list");
int n = Convert.ToInt32(Console.ReadLine());
List<String> userList = new List<String>();
String input;

Console.WriteLine("Enter the student names ");


for (int i = 0; i < n; i++)
{
userList.Add(input = Console.ReadLine());

Console.WriteLine("Student added in list are ");


foreach (var user in userList)
{
Console.WriteLine(user);

}
Console.Read();
}
}
}

Ouput:-
Practical 8: - Write a program to search the name of students in an array using “For each
loop”.
using System;
namespace Program_8
{
class Program
{
static void Main(string[] args)
{
string[] arr = { "abc", "def", "xyz","mno", "jkl" };
Console.WriteLine("Enter name of the student you want to search for ");
string studentName = Console.ReadLine();
Console.WriteLine("Students in the class\n");
for (int i = 0; i < arr.Length; i++)
{
Console.WriteLine(arr[i]);
}
Console.WriteLine();
foreach (string name in arr)
{
if (name == studentName) {
Console.WriteLine(studentName + " is present");
}
else
{
Console.WriteLine(studentName + " is not present");
}
Console.Read();
}

}
}
}
Output: -

You might also like