Question

A program where parent process counts number of vowels in the given sentence and child process...

A program where parent process counts number of vowels in the given sentence and child process will count number of words in the same sentence. The above programs should use system calls like fork and wait.

Homework Answers

Answer #1

Copyable Code:

#include<unistd.h>

#include<sys/types.h>

#include<stdio.h>

#include<stdlib.h>

fun_parent(char s[])

{

    int p,t_vowel;

    int a=0,e=0,i=0,o=0,u=0;

    for(p=0;s[p];p++)

    {

        switch(s[p])

        {

            case 'a':

            case 'A':a++;break;

            case 'e':

            case 'E':e++;break;

            case 'i':

            case 'I':i++;break;

            case 'o':

            case 'O':o++;break;

            case 'u':

            case 'U':u++;break;

        }

    }

    printf("\nTotal A or a = %d",a);

    printf("\nTotal E or e = %d",e);

    printf("\nTotal I or i = %d",i);

    printf("\nTotal O or o = %d",o);

    printf("\nTotal U or u = %d",u);

    t_vowel=a+e+i+o+u;

    printf("\nTotal noumber of vowels in the sentence = %d\n",t_vowel);

}

fun_child(char s[])

{

    int w=0,y=0,f=0;

    while(s[y]!='\0')

    {

        while(s[y]==' ' && s[y]!='\0')

        {

            y++;

        }

        while(s[y]!=' ' && s[y]!='\0')

        {

            y++;

            f=1;

        }

        if(f)

        {

            w++;

            f=0;

        }

    }

    printf("\nNumber of words in the sentence = %d\n",w);

}

int main()

{

    pid_t newPID;

    char s[100];

    printf("\nEnter sentence: ");

    gets(s);

    newPID = fork();

    if(newPID<0)

    {

        printf("\nError occured in process");

        exit(-1);

    }

    else if(newPID==0)

    {

        fun_child(s);

        exit(0);

    }

    else

    {

        execlp("a.out","vowelFork.c",fun_parent(s),NULL);

        sleep(10);

        wait();

        exit(0);

    }

    return 0;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following program calls the fork() system call to create a child process. Suppose that the...
The following program calls the fork() system call to create a child process. Suppose that the actual pids of the parent process and child process are as follows: Parent process: 801 Child process:   802 (as returned by fork) Assume all supporting libraries have been included. => Use the answer text field to write the values of the pids printed at lines 1, 2, 3, and 4 (indicate each line number and the value printed). int main() {      pid_t pid,...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course...
Program Assignment 1: Process Management Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme. Environment: Unix/Linux environment (VM Linux or Triton...
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
Create a MIPS program where you ask a user for 10 digit base 28 number and...
Create a MIPS program where you ask a user for 10 digit base 28 number and output a decimal in mips programming. It should also ignore any character that is not in the base 28 system and count its value as 0. Example: Input: 100000xza! Output: 17210368 Input: xyzxyzxyzx Output:0 Input: 1000000000 Output: 17210368 Output: 10578455953408 Input: 0000000000 Output:0
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
/* This program should check if the given integer number is prime. Reminder, an integer number...
/* This program should check if the given integer number is prime. Reminder, an integer number greater than 1 is prime if it divisible only by itself and by 1. In other words a prime number divided by any other natural number (besides 1 and itself) will have a non-zero remainder. Your task: Write a method called checkPrime(n) that will take an integer greater than 1 as an input, and return true if that integer is prime; otherwise, it should...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
43) In the process of preparing a receiving report, the receiving department should perform all of...
43) In the process of preparing a receiving report, the receiving department should perform all of the following tasks except: (2pts) compare the completed receiving report to the information stored in the purchase order master data inspect and approve quality count the quantity received compare the vendor’s packing slip to a copy of the purchase requisition 44) Which of the following data stores is updated for job specifications? (2pts) termination data skills inventory data labor-force planning data payroll data All...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • W Mart, one of major retailers, reported cash flows and earning: Comprehensive income) for the firm...
    asked 7 minutes ago
  • Parker Hi-Fi Systems Parker Hi-Fi Systems, located in Wellesley, Massachusetts, a Boston suburb, assembles and sells...
    asked 7 minutes ago
  • Manufacturing companies strive to maintain production​ consistency, but it is often difficult for outsiders to tell...
    asked 19 minutes ago
  • There is a difference between statistical probability and theoretical probability. The theoretical probability of rolling a...
    asked 25 minutes ago
  • In a small struggling technology company, the employees are aware that processes and structures must change...
    asked 37 minutes ago
  • On June 30, 2018, Blue, Inc. leased a machine from Large Leasing Corporation. The lease agreement...
    asked 47 minutes ago
  • You are on a mountain and see three other mountain tops that create a polygonal valley....
    asked 1 hour ago
  • Congressional Ethics: Identify one (1) member of Congress who has been charged with ethics violations in...
    asked 1 hour ago
  • A study had a statistically significant finding that walking 1 mile everyday will reduce the BMI...
    asked 1 hour ago
  • What is meant by electrical equivalent of heat. (define ) What is electrical energy and what...
    asked 1 hour ago
  • A block of mass 1.970  kg is free to slide on a frictionless, horizontal surface. A cord...
    asked 1 hour ago
  • A construction company purchased new equipment for $850,000. It has an estimated useful life of 15...
    asked 1 hour ago