Answer:
// here is code in C++
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int n,no_open=0;
cout<<"enter the number of lockers:";
// read the number of lockers
cin>>n;
// initialize all lockers with 0, 0 for locked and 1 for open
int lock[n]={};
// toggle the locks
// in each pass toggle every ith lock
// if open close it and vice versa
for(int i=1;i<=n;i++)
{
for(int a=0;a<n;a++)
{
if((a+1)%i==0)
{
if(lock[a]==0)
lock[a]=1;
else if(lock[a]==1)
lock[a]=0;
}
}
}
cout<<"After last pass status of all locks:"<<endl;
// print the status of all locks
for(int x=0;x<n;x++)
{
if(lock[x]==0)
{
cout<<"lock "<<x+1<<" is close."<<endl;
}
else if(lock[x]==1)
{
cout<<"lock "<<x+1<<" is open."<<endl;
// count the open locks
no_open++;
}
}
// print the open locks
cout<<"total open locks are :"<<no_open<<endl;
return 0;
}
Explanation:
First read the number of lockers from user.Create an array of size n, and make all the locks closed.Then run a for loop to toggle locks.In pass i, toggle every ith lock.If lock is open then close it and vice versa.After the last pass print the status of each lock and print count of open locks.
Output:
enter the number of lockers:9
After last pass status of all locks:
lock 1 is open.
lock 2 is close.
lock 3 is close.
lock 4 is open.
lock 5 is close.
lock 6 is close.
lock 7 is close.
lock 8 is close.
lock 9 is open.
total open locks are :3
Answer:
Codes of conduct
Explanation:
Codes of conduct are a set of rules or norms established by an organization for all employees, students or users, to ensure individual responsibilities and proper practices. The code of conduct can cover overall behaviour of individuals in an organization, but a specific code of conduct can be developed for proper computer use in order to establish what is appropriate and available to use in the organization´s computers, and also to restrict or avoid non related content.
Answer: d) Exploit
Explanation: Exploit is a type computer attack that successful when the computer system of an user is vulnerable and attacker can do the exploitation. This happens due to the weakness of the system, applications software, network etc.
Other given option are incorrect because exit door,glitch and bad are not any type of attack in the computer field that causes harm to the system.Thus the correct option is option(d).
Answer:
public String toString() {
return "#(" + red + "," + green + "," + blue + ")";
}
Explanation:
The code:
public String toString() {
return "#(" + red + "," + green + "," + blue + ")";
}
Is a tostring java code, and it is so easy to write one, as compare to other programming languages
Writing a tostring method returns a strinb representation of an object in Java. Normally, the toString method returns the name of the object’s class plus its hash code.
This code creates a new colour object; then the result of its toString method is printed to the console.
Tostring method can be override. The default implementation of toString isn’t very useful in most situations. So, one can just override it.