#include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <ctype.h> void printLower(char *s) { int i = 0; while(s[i] != '\0') { printf("%c", tolower(s[i++])); } printf("\n"); } void printUpperRev(char *s) { if(s[0] == '\0') { return; } printUpperRev(s + 1); printf("%c", toupper(s[0])); } int main(int argc, char *argv[]) { if(argc < 2) { printf("Error! enter a command line parameter.\n"); return 0; } int pid = fork(); if(pid == 0) { // child process printf("In child process: "); printLower(argv[1]); } else { printf("In parent process: "); printUpperRev(argv[1]); printf("\n"); } }
Please upvote, as i have given the exact answer as asked in
question. Still in case of any issues in code, let me know in
comments. Thanks!
Write a C or C++ program A8p1.c(pp) that accepts one command line string parameter. Call the...
Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string (‘A’<->’Z’, ‘B’<->’Y’, ‘C’<->’X’, etc). You should divide this conversion task among the n threads as evenly as possible. Print out the string both before...
1. (50 pts) Write a C or C++ program A6p1.c(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string ('A'<>'Z', 'B'<->'Y', 'C''X', etc). You should divide this conversion task among the n threads as evenly as possible, Print out the...
Follow the example programs unix_pipe.c, named_pipe.c and shm-posix-combined.c to write three versions (two pipe versions and one shared memory version) of an interprocess communication program (A8p2_unixpipe.c[pp], A8p2_namedpipe.c[pp] and A8p2_shm.c[pp]) in C/C++. Each version should create two processes using fork. One of the two processes should send or share twenty random integers a1,…,a20 in the range from -19 to 19 inclusive to the other process. The sending process should print out the values of these integers. The receiving process should decide and print out whether the two vectors (a1,…,a10) and...
Please, please help! (Programming Assignment: fork gymnastics) Write a C/C++ program (call it string-invert) that takes a string argument from the command line and outputs the string in reversed order You have two constraints: Constraint 1: Each process can output at most one character. If you want to output more than a single character, you must fork off one or more processes in order to do that, and each of the forked processes in turn outputs a single character t...
Write a C or C++ program A6p1.c[pp] that accepts two command line arguments n and m where n is an integer between 2 and 6 inclusive and m can be assumed to be a multiple of 60 (e.g. 60,120,etc). Generate a string of m random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string of m chars in place into an off-by-one lower case version (i.e. ‘A’→’b’, ‘B’→’c’, ‘C’→’d’,…, ‘Y’→’z’, ‘Z’→’a’). You should divide this conversion task among the n threads as evenly as possible. Print out the string both...
Write a program in C using the fork() system call to do the following. The parent process (main program) forks a process (CHILD 1) to compute and print the sum of first n integers where n is a variable shared between the parent and CHILD 1. It also forks another process (CHILD 2) that finds the sum of squares of the first n numbers where n is a variable it shares with the parent. Let CHILD 1 print “The sum...
Write a C or C++ program A6pc(pp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random upper case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into a complementary string (‘A’<->’Z’, ‘B’<->’Y’, ‘C’<->’X’, etc). You should divide this conversion task among the n threads as evenly as possible. Print out the string both before...
Write a program using the fork() system call to do thefollowing. The parent process (main program) forks a process(CHILD 1) to compute and print the sum of first n integers where n is a variable shared between the parent and CHILD 1. Have the parent invoke the wait () call to wait for both the child processesto complete before exiting the program. IN A C program
Q4) Write a C program named "hw3q4.c” that takes three string inputs from the command line arguments that represent file names. The first and second files contain four sorted integer numbers that represent set elements. The main process creates a child process that shares the three files. The child process determines the intersection set of two sets and saves the line: "Child process PID: xxxx Intersection of (x, x, x, x) and (y, y, y, y) (z, z, z, z)"...
Write a C program called test that takes one command line argument, an integer N. When we run test: ./test N the program will do this: the parent process forks N child processes each child process prints its process ID, exits the parent process waits for all child processes to exit, then exits