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

What Is A Command Prompt

Uploaded by

Fayera Ababa
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)
19 views11 pages

What Is A Command Prompt

Uploaded by

Fayera Ababa
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/ 11

What is a Command Prompt?

A Command Prompt is basically a Command Line Interface. It is an application in which the


user enters commands and the operations are executed accordingly. The Command Prompt is
an integral part of the Windows Operating System.
How to Access Command Prompt?
To access the command prompt there are two ways:
First way
 Click on the Start Menu or press the Windows logo button from the keyboard.
 Type 'cmd' or 'Command Prompt' in the search bar.
 Click on the command prompt from the search results.
Second way
 Press Windows+R from the keyboard.
 Type 'cmd' in the Run dialog box.
 Click on OK.

Tips for Opening Command Prompt in Windows 11

 Use shortcuts: Pressing Windows + X and then selecting Command Prompt from the
menu is a handy shortcut.
 Run as Administrator: If you need elevated privileges, right-click on “Command Prompt”
and select “Run as administrator.”
 Pin to Taskbar: For quick access, right-click on the Command Prompt icon in the Start
menu and select “Pin to taskbar.”
 Use PowerShell: Windows 11 might show PowerShell instead of Command Prompt. You
can use PowerShell similarly or search specifically for Command Prompt.
 Keyboard navigation: After pressing Windows + X, you can use the arrow keys to
navigate to the Command Prompt option.

1. ping (test network connection)

The ping command tests network connectivity between two devices by sending ICMP echo
requests. For example, computer A tests if it has connectivity to computer B by sending some
packets back and forth.

The ping command is still one of my favorite tools for testing basic network connectivity. It’s
fast and very easy to use. In addition, I use it for the following:

 Test for packet loss


 Test latency
 Test DNS queries
 Test connectivity with configuring new connections (can my router talk to the next hop
such as the ISPs router?)
Ping Examples

To test the connectivity to another device by IP use the command below.

ping 192.168.100.1
2. ipconfig (get network adapter details)

The ipconfig command is used to display a computers TCP/IP configuration. You can display the
IP info for a single or all network cards installed on a computer.

3. netstat command examples

Display all active and listening ports.

netstat -a

Display all connections in numerical order.

netstat -a -n

4. cls (clear screen)

The cls command will clear the command prompt console. This is useful when the screen has a
lot of information on it and you want a blank screen.

At the windows command prompt type cls and press enter to clear the screen.

5. diskpart

Diskpart allows you to manage disks, partitions, and volumes on your local computer. You can
delete, create, format, extend and shrink volumes.

To display a list of disks on the local computer is these commands.

diskpart

list disk

6. schtasks (scheduled tasks)

The schtasks commands lets you add, remove, change and view scheduled tasks on the local
computer.

View scheduled tasks:

Schtasks
With C++ Code Scheduling algorithms

FCFS

#include<iostream>
using namespace std;
int main()
{
int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
cout<<"Enter total number of processes(maximum 20):";
cin>>n;
cout<<"\nEnter Process Burst Time\n";
for(i=0;i<n;i++)
{
cout<<"P["<<i+1<<"]:";
cin>>bt[i];
}
wt[0]=0; //waiting time for first process is 0
//calculating waiting time
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
}

cout<<"\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time";


//calculating turnaround time
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
avwt+=wt[i];
avtat+=tat[i];
cout<<"\nP["<<i+1<<"]"<<"\t\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
}
avwt/=i;
avtat/=i;
cout<<"\n\nAverage Waiting Time:"<<avwt;
cout<<"\nAverage Turnaround Time:"<<avtat;
return 0;
}
SJN
#include <iostream>
using namespace std;
int main() {
int A[100][4];
int i, j, n, total = 0, index, temp;
float avg_wt, avg_tat;
cout << "Enter number of process: ";
cin >> n;
cout << "Enter Burst Time:" << endl;
for (i = 0; i < n; i++) {
cout << "P" << i + 1 << ": ";
cin >> A[i][1];
A[i][0] = i + 1;
}
for (i = 0; i < n; i++) {
index = i;
for (j = i + 1; j < n; j++)
if (A[j][1] < A[index][1])
index = j;
temp = A[i][1];
A[i][1] = A[index][1];
A[index][1] = temp;
temp = A[i][0];
A[i][0] = A[index][0];
A[index][0] = temp;
}
A[0][2] = 0;
for (i = 1; i < n; i++) {
A[i][2] = 0;
for (j = 0; j < i; j++)
A[i][2] += A[j][1];
total += A[i][2];
}
avg_wt = (float)total / n;
total = 0;
cout << "P BT WT TAT" << endl;
for (i = 0; i < n; i++) {
A[i][3] = A[i][1] + A[i][2];
total += A[i][3];
cout << "P" << A[i][0] << " " << A[i][1] << " " << A[i][2] << " " << A[i][3] <<
endl;
}
avg_tat = (float)total / n;
cout << "Average Waiting Time= " << avg_wt << endl;
cout << "Average Turnaround Time= " << avg_tat << endl;
}
Priority
#include <bits/stdc++.h>
using namespace std;
struct Process {
int pid; // Process ID
int bt; // CPU Burst time required
int priority; // Priority of this process
};
bool comparison(Process a, Process b)
{
return (a.priority > b.priority);
}
void findWaitingTime(Process proc[], int n, int wt[])
{
wt[0] = 0;

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


wt[i] = proc[i - 1].bt + wt[i - 1];
}
void findTurnAroundTime(Process proc[], int n, int wt[],
int tat[])
{
for (int i = 0; i < n; i++)
tat[i] = proc[i].bt + wt[i];
}
void findavgTime(Process proc[], int n)
{
int wt[n], tat[n], total_wt = 0, total_tat = 0;
findWaitingTime(proc, n, wt);
findTurnAroundTime(proc, n, wt, tat);
cout << "\nProcesses "
<< " Burst time "
<< " Waiting time "
<< " Turn around time\n";
for (int i = 0; i < n; i++) {
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
cout << " " << proc[i].pid << "\t\t" << proc[i].bt
<< "\t " << wt[i] << "\t\t " << tat[i]
<< endl;
}
cout << "\nAverage waiting time = "
<< (float)total_wt / (float)n;
cout << "\nAverage turn around time = "
<< (float)total_tat / (float)n;
}
void priorityScheduling(Process proc[], int n)
{
sort(proc, proc + n, comparison);
cout << "Order in which processes gets executed \n";
for (int i = 0; i < n; i++)
cout << proc[i].pid << " ";
findavgTime(proc, n);
}
int main()
{
Process proc[]
= { { 1, 10, 2 }, { 2, 5, 0 }, { 3, 8, 1 } };
int n = sizeof proc / sizeof proc[0];
priorityScheduling(proc, n);
return 0;
}
RR
#include <climits>
#include <iostream>
using namespace std;
struct Process
{
int AT, BT, ST[20], WT, FT, TAT, pos;
};
int quant;
int main()
{
int n, i, j;
cout << "Enter the no. of processes: ";
cin >> n;
Process p[n];
cout << "Enter the quantum: " << endl;
cin >> quant;
cout << "Enter the process numbers: " << endl;
for (i = 0; i < n; i++)
cin >> p[i].pos;
cout << "Enter the Arrival time of processes: " << endl;
for (i = 0; i < n; i++)
cin >> p[i].AT;
cout << "Enter the Burst time of processes: " << endl;
for (i = 0; i < n; i++)
cin >> p[i].BT;
int c = n, s[n][20];
float time = 0, mini = INT_MAX, b[n], a[n];
int index = -1;
for (i = 0; i < n; i++)
{
b[i] = p[i].BT;
a[i] = p[i].AT;
for (j = 0; j < 20; j++)
{
s[i][j] = -1;
}
}
int tot_wt, tot_tat;
tot_wt = 0;
tot_tat = 0;
bool flag = false;
while (c != 0)
{
mini = INT_MAX;
flag = false;
for (i = 0; i < n; i++)
{
float p = time + 0.1;
if (a[i] <= p && mini > a[i] && b[i] > 0)
{
index = i;
mini = a[i];
flag = true;
}
}
if (!flag)
{
time++;
continue;
}
j = 0;
while (s[index][j] != -1)
{
j++;
}
if (s[index][j] == -1)
{
s[index][j] = time;
p[index].ST[j] = time;
}
if (b[index] <= quant)
{
time += b[index];
b[index] = 0;
}
else
{
time += quant;
b[index] -= quant;
}
if (b[index] > 0)
{
a[index] = time + 0.1;
}
if (b[index] == 0)
{
c--;
p[index].FT = time;
p[index].WT = p[index].FT - p[index].AT - p[index].BT;
tot_wt += p[index].WT;
p[index].TAT = p[index].BT + p[index].WT;
tot_tat += p[index].TAT;
}
} // end of while loop
cout << "Process number ";
cout << "Arrival time ";
cout << "Burst time ";
cout << "\tStart time";
j = 0;
while (j != 10)
{
j += 1;
cout << " ";
}
cout << "\t\tFinal time";
cout << "\tWait Time ";
cout << "\tTurnAround Time" << endl;

for (i = 0; i < n; i++)


{
cout << p[i].pos << "\t\t";
cout << p[i].AT << "\t\t";
cout << p[i].BT << "\t";
j = 0;
int v = 0;
while (s[i][j] != -1)
{
cout << p[i].ST[j] << " ";
j++;
v += 3;
}
while (v != 40)
{
cout << " ";
v += 1;
}
cout << p[i].FT << "\t\t";
cout << p[i].WT << "\t\t";
cout << p[i].TAT << endl;
}
double avg_wt, avg_tat;
avg_wt = tot_wt / static_cast<double>(n);
avg_tat = tot_tat / static_cast<double>(n);
cout << "The average wait time is: " << avg_wt << endl;
cout << "The average TurnAround time is: " << avg_tat << endl;
return 0;
}

In Windows, we use dir call to list all directories, and in most of the
other Operating Systems “ls” is used. Below is a simple C++
implementation to list directories of folders irrespective of OS.
 C++
 C

// C++ program to list all directories.


#include <bits/stdc++.h>

using namespace std;

int main()

#ifdef _WIN32

system("dir");

#else

system("ls");

#endif

return 0;

FIFO
#include <iostream>
using namespace std;

int main()
{
int incomingStream[] = {7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1};
int pageFaults = 0;
int frames = 3;
int m, n, s, pages;

pages = sizeof(incomingStream)/sizeof(incomingStream[0]);

printf("Incoming \t Frame 1 \t Frame 2 \t Frame 3");


int temp[frames];
for(m = 0; m < frames; m++)
{
temp[m] = -1;
}

for(m = 0; m < pages; m++)


{
s = 0;
for(n = 0; n < frames; n++)
{
if(incomingStream[m] == temp[n])
{
s++;
pageFaults--;
}
}
pageFaults++;

if((pageFaults <= frames) && (s == 0))


{
temp[m] = incomingStream[m];
}
else if(s == 0)
{
temp[(pageFaults - 1) % frames] = incomingStream[m];
}

cout << "\n";


cout << incomingStream[m] << "\t\t\t";
for(n = 0; n < frames; n++)
{
if(temp[n] != -1)
cout << temp[n] << "\t\t\t";
else
cout << "- \t\t\t";
}
}

cout << "\n\nTotal Page Faults:\t" << pageFaults;


cout << "\nTotal Hits :\t" << pages - pageFaults;
return 0;
}

You might also like