write a code for a program in which the parent had to ask from user that how many child user wants to create and then it should fork that many Childs?

Answers

Answer 1

Answer:

//same program different code

#include<stdio.h>

#include<unistd.h>

#include<stdlib.h>

int main()

{

   int pid;

   pid=fork();

   if(pid<0)

   {

       printf("\n Error ");

       exit(1);

   }

   else if(pid==0)

   {

       printf("\n Hello I am the child process ");

       printf("\n My pid is %d ",getpid());

       exit(0);

   }

   else

   {

       printf("\n Hello I am the parent process ");

       printf("\n My actual pid is %d \n ",getpid());

       exit(1);

   }

}

Explanation:

Answer 2

Following are the program to the given question:

Program Explanation:

Include header file.Defining the main method.Defining an integer variable "n, i", after defining this use "n" to the input value.In the next step, a loop is declared that uses if block that checks fork value equal to 0, in which it calls the sleep method and prints its value.At the last, it calls the wait method.  

Program:

#include<stdio.h>//header file

#include<sys/types.h>

#include<sys/wait.h>

#include<unistd.h>

int main()//defining the main method

{

   int n,i;//defining an integer variable

   printf("Enter the number of child to be created:"); //print message

   scanf("%d", &n);//input value in n

   for(i=0;i<n;i++) // defining a loop that use if block with the frok method to print value  

   {

       if(fork() == 0)//use if that check fork method value equal to 0

       {

           sleep(3);//calling sleep method

           printf("[child] pid %d from [parent] pid %d\n",getpid(),getppid());//print message

       }

   }

   wait(NULL);//calling wait method

   return 0;

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/17925458

Write A Code For A Program In Which The Parent Had To Ask From User That How Many Child User Wants To

Related Questions

Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user.
Open the tsv file and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90= B: 80=< X < 90
C: 70=< X < 80
D: 60=< X < 70
E: X < 60
Compute the average of each exam.
• Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt.
• Output one student per row and separate the values with a tab character.
• Output the average of each exam, with two digits after the decimal point at the end of report.txt. Hint: Use the setprecision manipulator to format the output.
Ex: If the input of the program is:
StudentInfo.tsv
and the contents of Studentinfo tsv are:
Barrett Edan 70 45 59
Bradshaw Reagan 96 97 88
Charlton Caius 73 94 80
Mayo Tyrese 88 61 36
Stern Brenda 90 86 45
the file report.txt should contain:
Barrett Edan 70 45 59 F
Bradshaw Reagan 96 97 88 A
Charlton Caius 73 94 80 B
Mayo Tyrese 88 61 36 D
Stern Brenda 90 86 45 C
Averages: midtermi 83.40, midterm2 76.60, final 61.60

Answers

#include
#include
#include
#include
#include
#include


using namespace std;

// Class student required to store the data
class Student{
public:
string lname;
string fname;
int marks[3];
char grade;

// Function which generates the grade for student
void calculate_grade(){
double sum = 0;
for(int i=0;i<3;i++){
sum+= marks[i];
}
double average = sum/3;
if(average>=90 && average<100)
this->grade = 'A';
else if(average>=80)
this->grade = 'B';
else if(average>=70)
this->grade = 'C';
else if(average>=60)
this->grade= 'D';
else this->grade = 'F';
}
};

// This function reads the file , and creates a vector of Students data
vector read_file(string fileName){

// Opening the file
fstream fin;
fin.open(fileName);


// Temp variables
vector list;
vector row ;
string line, word, temp;

// Read the data into vector
while(getline(fin,line)){
row.clear();
stringstream s(line);

while(getline(s,word,'\t')){

row.push_back(word);

}
Student st;
st.fname = row[0];
st.lname = row[1];
st.marks[0] = stoi(row[2]);
st.marks[1] = stoi(row[3]);
st.marks[2] = stoi(row[4]);
st.calculate_grade();
list.push_back(st);
}
fin.close();
return list;
}

// This function takes filname to be output as input, and list of student
void writeFile(string filename, vector list){

// Opening the new file
ofstream fin(filename);
for(int i=0;i string line = list[i].fname+"\t"+list[i].lname+"\t"+to_string(list[i].marks[0])+"\t"
+to_string(list[i].marks[1])+"\t"+to_string(list[i].marks[2])+"\t"+list[i].grade+"\n";
fin<
}


// Find the stats required
double average1 =0,average2 =0 ,average3 = 0;
for(int i=0;i average1+=list[i].marks[0];
average2+=list[i].marks[1];
average3+=list[i].marks[2];
}
average1/=list.size();
average2/=list.size();
average3/=list.size();

// Writting the stats
fin<<"\n"<<"Average: "<<"mid_term1 "<
// Closing the file
fin.close();
}
int main(){

// Taking the input
cout<<"Enter the filename: ";
string filename;
cin>>filename;
vector list;

// Reading and Writting to the file
list = read_file(filename);
writeFile("report.txt",list);


}

Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even and how many of them are odd.

Answers

Answer:

import random

numbers = []

even = 0

odd = 0

for i in range(100):

   numbers.append(random.randint(1, 200))

for i in range(100):

   if numbers[i] % 2 == 0:

       even += 1

   else:

       odd += 1

print("Even:", even)

print("Odd:", odd)

Explanation:

Gg ez.

(a) Explain what the following Java components are used for.JListJFrameFLowLayoutJpanelJFrameEventListener(b) Write simple Java codes to illustrate how each one of the above components are implemented.​

Answers

Answer:

Welcome to Gboard clipboard, any text you copy will be saved here.

why do you think mobile devices have CPUs that are less powerful than those in a larger desktop computer?

Answers

Mobile CPUs are found in laptops and are often slower than their desktop counterparts because they have to be more power-efficient and generate less heat. High power consumption and high heat generation can be a problem for a battery-powered laptop with a relatively small chassis

Mobile devices have CPUs that are less powerful than those in a larger desktop computer needs power as well as the device memory that was needed is not present.

What is CPU?

The central processing unit also known as CPU is an important part of the computer as it posses the part where the basic functions like taking actions, input or ouput etc. This all process needs high power and battery as well as storage.

For a battery excessive electricity utilization and significant temperature rise can just be problems. The CPU of a device cannot be powered at higher, continuous levels using such a little battery.

As a result, the most recent cellphone cannot compete with the performance of a top-tier desktop computer. the processor as well as the battery is needed for a CPU that can not be in mobiles.

Learn more about CPUs, here:

https://brainly.com/question/16254036

#SPJ2


• R7.9 Write enhanced for loops for the following tasks.
a. Printing all elements of an array in a single row, separated by spaces.
b. Computing the maximum of all elements in an array.
2. Counting how many elements in an array are negative.

Answers

Answer:

a is the correct answer

Explanation:

correct me if I'm wrong hope it's help thanks

Define Word Processing

Answers

Answer:

Word Processing refers to the act of using a computer to create, edit, save and print documents. ... Text can be inserted, edited, moved, copied or deleted within your document and the appearance of the text can be modified in numerous ways.

Diane, a developer, needs to program a logic component that will allow the user to enter a series of values

Answers

The Examples Of Users:FormTableQueryThe Answers Are:Formatted summary of information from a database

User-friendly interface for adding to or retrieving information from a database

Stores raw data in a relational database

Retrieves specific information from a database. Can also be used to update, edit, and remove dataHope it helps*^-^*All Correct!?

If a client must wait too long for software that works, he might attempt to add requests for more and more features to be added to the program. This is known as ________.

Answers

Answer:

scope creep

Explanation:

explain the use of mail merge feature.
pls help​

Answers

Mail Merge is a handy feature that incorporates data from both Microsoft Word and Microsoft Excel and allows you to create multiple documents at once, such as letters, saving you the time and effort of retyping the same letter over and over.

hi hi hihihihihivvv hihihihihihi v vhi

Answers

Answer: hihihihihihiihihi hihihihiihihih

Explanation: hi.

I really need help with this question! Please help!

Answers

Answer:

(C) Emma goes to sleep late and does not set an alarm.

Explanation:

Decomposing a problem is setting a back drop inference as to (WHY?) something happens . So Emma woke up late , the only reasonable (WHY?) in this question would be (C)

check image dont answer if you dont know please

Answers

Answer:

Explanation:

1-2nd option

2-1st option

3-last option

hope this helps!! have a good rest of ur day!! <3

Write a python program to calculate the sum of three numbers and as well require the user to input the numbers.​

Answers

Answer:

numbers = []

for i in range(3):

 numbers.append(eval(input("Enter number: ")))

print('Sum is:', sum(numbers))

Explanation:

You want to use a loop to prevent repeating your code.

Answer:

numbers = []

for i in range(3):

numbers.append(eval(input("Enter number: ")))

print('Sum is:', sum(numbers))

13) You notice that the row labels in your spreadsheet are 1, 2, 3, 8, 9.
Row labels 4 through 7 are missing. What could cause this?

Answers

Possible reasons for missing out row 4 to 7 are as follows,

Chance of rows from 4 to 7 contain incorrect/ non formatted data.Chance of rows from 4 to 7 are in hidden state.Chance of rows from 4 to 7 are assigned to some other user which does not belongs to your current user.Chance of rows from 4 to 7 were deleted from the sheet.

These are all the possible reasons for missing of row 4 to 7.

Learn more:  https://brainly.com/question/24504878

Brainliest if correct. 5. if you wanted b show how many employees at your office ride a bicycle to work in
comparison to the number of employees who drive a car, take public transportation,
or walk wihat visual would be best? (1 point)

Answers

Answer:

I believe a bar graph would be best for me. What are your answer options though?

Explanation:

People can use computers for sending ....... writing reports, listening to music and playing games. ​

Answers

Answer:

the answer is messages, emails, texts

Hope This Helps!!!

Answer:

People can use computers for sending   MESSAGES'TEXT'EMAILS   ,writing reports,listening to music and playing games....

state an application that would be better to write c++ than java and give a rationale for your answer

Answers

Microsoft Visual Studio is the best deal

Question 4 A data analyst wants to include a line of code directly in their .rmd file in order to explain their process more clearly. What is this code called

Answers

A line of code that can be inserted directly into a .rmd file is called an inline code.

R Markdown (.rmd file) is a file format that is typically used for making dynamic documents by using R Studio and R programming language. Also, R Markdown files can be used in the following ways:

To save, organize, and document an executable code.To create a record of any cleaning process.To generate reports containing an executable code for stakeholders.

In R Studio, an inline code is a line of code that can be inserted directly into a R Markdown (.rmd file), in order to explain a process more clearly.

Read more on R Markdown here: https://brainly.com/question/25558534

I have a D in one of my majors, I got a lot of 70s and I'm failing music. im in middle school. Will I be held back? Please answer this

Answers

Answer:

probably sorry it will be okay

Depends on where you’re from and what grading scale is used. I wouldn’t say you’re ruined if you push hard the rest of the year.

At what layer in the TCP/IP protocol hierarchy could a firewall be placed to filter incoming traffic by means of:

a) message content
b) source address
c) type of application​​

Answers

The answer is c) type of application

The most significant protocol at layer 3, often known as the network layer, is the Internet Protocol, or IP.The IP protocol, the industry standard for packet routing among interconnected networks, is the source of the Internet's name.  Thus, option C is correct.

What are the TCP/IP protocol hierarchy could a firewall?

Application-layer firewalls operate at the TCP/IP stack's application level (all browser traffic, or all telnet or ftp traffic, for example), and thus have the ability to intercept any packets going to or from an application. They stop different packets (usually dropping them without acknowledgment to the sender).

Firewalls are frequently positioned at a network's edge. An external interface is the one that is located outside the network, while an internal interface is the one that is located inside the firewall.

Therefore, The terms “unprotected” and “protected,” respectively, are sometimes used to describe these two interfaces.

Learn more about TCP/IP here:

https://brainly.com/question/27742993

#SPJ2

VPN or Proxy is safer?

Answers

Proxy chain is safer

Complete the statement using the correct term.
The [blank] of the site is what will be displayed on the web page.

answer is Body

Answers

The BODY of the site is what will be displayed on the web page. It contains most of the distinctive content of the web page.

A web page refers to a document exhibited by the browser, which is generally written in the HTML language.

The body of a web page is a big area in the center that contains the most important and distinctive content of a web page.

The body will determine the central content of the HTML document, which will be observable on the web page (e.g., a photo gallery).

Learn more about a web page here:

https://brainly.com/question/16515023

Identifies 3 different companies that use Information Systems. Then for each company describe the WHAT the company actually uses, the HOW the company uses it, and the WHY the company needs to implement this system within itself.

Answers

Three companies that use information systems:

IBM:

This company has been using an information management system for transactional and database operations. It was first used in 1968. Till then the system has gone through many modifications as per the changing requirements of the company. The information system used by IBM helps in defining structure for database, an organization for data, query management, database transactions, etc.

Olive:

This company uses a health-based information system. The information system used by this company aims at offering customers and users a regularly updated information base. They can access current research and technical documents. The content is in simple language and accessible in many locations. It gives a portal-like feature that is used to provide data published by experts, key researchers, findings, etc.

Catalyte:

The information system used by this company is a blend of high technology and a diverse workforce. They offer machine learning guided information systems to train candidates, speed up their performance, and generate quality results. Their information systems offer new career options as well as opportunities to develop software using various forums, communities, etc.

The companies that use Information Systems are

Amazon IBMRRE Ventures

How does Ama.zon use information systems?

Ama.zon uses  information systems in a  lot of its business processes as it helps them to have good and improved efficiency in the the area of collection, storage, and analytics of all their customers' information.

Conclusively, IBM uses the information system for:

Keeping of customers information.communicating.Buying and selling etc.

Learn more about  Information Systems from

https://brainly.com/question/14688347

Complete the sentence based on the given information.

______ are responsible for analyzing the client business model, whereas _____ are responsible for identifying errors in the software product to confirm that it meets the client model.

Answers

Answer:

blank answer so brainly doesnt delete your question.

Explanation:

list 3 things needed in order to complete mail merge process.



pls help me!​

Answers

There are three documents that are involved in the mail merge process:

1- the main document
2- the data source
3- the merged document.

what are organization tools?

Answers

an app or software created to optimize your daily task performance

A Product Manager has been given responsibility for overseeing the development of a new software application that will be deployed to a group of Accenture clients.

What would be the most time-saving and cost-effective way for the Product Manager to address the new application’s security considerations?


Utilize a DevSecOps approach to incorporate security into the development process from the beginning.


Schedule development of security features after the application’s initial release.


Design the application’s security features after the application’s initial build is complete.


Contract with an external vendor to develop a security solution separately from the main application.


I don't know this yet.

Answers

There are different software that has been developed today. The most time-saving and cost-effective way is to Design the application’s security features after the application’s initial build is complete.

Accenture is known for their work in improving business needs. They are constantly shifting to a new method of delivering information technology.

They are known to embed security into the product development life cycle helps secure the business and also keeping speed and assisting to remove friction.

Learn more about Accenture from

https://brainly.com/question/25737623

describe the process of terminating a crossover cable​

Answers

Background: In the Information Technology World, the Ethernet cable has been the most trusted medium that is link computers to the world wide web. However, in recent years, wireless technology has limited the use of the Ethernet cable. Nonetheless, true computer geeks know that in order to receive optimum speed within a computer network in a business or inside our homes; the proper cabling technics are crucial when installing a computer network. Therefore, this instructable will provide step-by-step procedures on the proper way to terminate a CAT 6 cable using the TIA 568B standard for a straight-through cable. The procedures used for the straight-through cable can also be utilized to terminate a cross-over and roll-over cable.

Cable Pin-outs: Straight-Through, Cross-over, and Roll-over cables

Step 1: Prepare the cable

Using the cable snips, remove approximately one half inch of outer cable sheath/jacketing from each cable end.

Step 2: Cut cable wires to the appropriate length

Cutting the wires to the proper length allows for the CAT 6 cable to properly fit in the RJ-45 connector.

Step 3: Align cable wires for the specific configuration that will be terminated

The alignment of the wires will ensure they enter the proper channel within the RJ-45 connector when inserting the wires.

Step 4. Slide cable into the RJ-45 Connector

When sliding the cable into the RJ-45 connector, use enough force to ensure the end of the wires are seated firmly at the end of the RJ-45 connector channels.

Step 5. Insert the RJ-45 connector in the crimping tool and Crimp the RJ-45 connector

When inserting the cable into the crimping tool, use enough force to ensure that the cable doesn’t slide out of the crimping tool and the wires do not become misaligned. In addition, while crimping the connector, use enough force to push the copper conductors down on to the wires and the plastic tab on to the outer sheath of the cable. You will hear a click once all the copper tabs are seated properly.

Step 6. Perform a visual inspection of the connector

The visual inspection is to ensure that the connector is properly terminated to the cable. Look for issues with wire alignment and connector looseness.

Step 7. Repeat steps to terminate multiple connectors.

Alexis plans to stop trading once she lose 5% of her account balance, her account balance is $215.00. How much money is she willing to lose ?

Answers

Answer:

She's willing to lose $10.75.

Explanation:

$215.00 * .05 = answer

         or

$215.00 * .95 = x

$215.00 - x = answer

What is a shell programming? Write a shell program to get the following details from the student: NAME, AGE, USN and GENDER. Output all the details to the terminal and also display message whether the student is eligible to vote or not

Answers

Shell programs are computer programs designed to run on the Unix/Linux shell

The shell program where comments are used to explain each line is as follows:

#This gets input for NAME

read NAME  

#This gets input for AGE

read AGE  

#This gets input for USN

read USN

#This gets input for GENDER

read GENDER

#This prints the name

echo "Name: $NAME"

#This prints the age

echo "Age: AGE"

#This prints the usn

echo "USN: USN"

#This prints the gender

echo "GENDER: $GENDER"

#The following if condition determines, if the user is eligible to vote or not

if [ $USN -gt 50 ] then

echo "You are not eligible"

else

echo "You are eligible"

Read more about computer programs at:

https://brainly.com/question/13795586

Other Questions
How much did the U.S. pay for the Philippines, Guam, and Puerto Rico?A. NothingB. $100,000C. $1 MillionD. $5 MillionE. $20 Million 12 - 33/4 equal in fraction form? 37. Rococo style developed at what time? (1 point)fifteenth centurysixteenth centuryO seventeenth centuryO eighteenth century38. The Easter Island heads are also known by which name? (2 Free cash flow equals cash provided by operations less capital expenditures and cash dividends. True False Why did people in Germany fear the Schutzstaffel (SS)?OAThe SS encouraged forced migration, which changed the German demographyOB.The SS created fear in the minds of the Germans by resorting to violence..The SS men used to attack women and girls outside clubs and colleges.ODThe SS attacked veterans who demanded their pensions for fighting the World War.O E.The SS announced a second World War and gambled Germany's overseas colonies in it. Which graph represents a reflection of f(x) = 6(0. 5)x across the x-axis?. The number of purchases made on a new online store is modeled byp(d) 15d + 45, where d is the number of days since the store opened.The average amount spent in dollars per purchase is modeled bys(d) = 0.15d? 4d + 80. Write a function R(d) to model the total dailyrevenue. Then predict the total amount of revenue on the 23rd day.- dr. piccolo is working with a family and determines that the parents do not make rules together and often contradict each other. this leads to confusion among the children who act out because they dont understand what is expected of them in the home. she helps them to get ""on the same page"" with regard to each family members place in the home and helps the parents work on their own relationship as co-parents. this is called ________ family therapy. [tex] \sf2 + 63 - 36 - 2[/tex]Here's some points ~ Which of these best describes the relationship between the incident ray, the reflected ray, and the normal for a curved mirror?(1 point)The angle that the incident ray makes with the normal is different than the angle that the reflected ray makes with the normal. All points on a curved mirror have the same normal.The angle that the incident ray makes with the normal is different than the angle that the reflected ray makes with the normal. All points on a curved mirror have the same normal.The angle that the incident ray makes with the normal is the same as the angle that the reflected ray makes with the normal. Different points on a curved mirror have a different normal.The angle that the incident ray makes with the normal is the same as the angle that the reflected ray makes with the normal. Different points on a curved mirror have a different normal.The angle that the incident ray makes with the normal is different than the angle that the reflected ray makes with the normal. Different points on a curved mirror have a different normal.The angle that the incident ray makes with the normal is different than the angle that the reflected ray makes with the normal. Different points on a curved mirror have a different normal.The angle that the incident ray makes with the normal is the same as the angle that the reflected ray makes with the normal. All points on a curved mirror have the same normal. Pls answer correctly thnksSolve the linear equation by elimination:-5x+3y=102x+5y=-35And explainThanks! how many moles of carbonate are there in sodium carbonate What is the circumference of the top of the water buoy? Round your answer to the nearest tenth.37.7 feet28.3 feet113.0 feet84.8 feet Hello, can you help me? I don't speak English, I speak Spanish and I don't understand anything. I use a translator to communicate, I give brainliest !! How did West Africa prosper? 6 remainder 1 as a fraction how many years of college to be an anesthesiologist? Which larger shape would be made if the two sections are fitted together?. 3. a car takes off with initial velocity of 20m/s and move with uniform acceleration of 12m/s2 for 20s. It maintained a constant velocity for 30s and come to rest with uniform acceleration of 2m/s2. Calculate the total distance covered by the car. What is chemistry,define it ?