Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C or C++ program A6p3.c (or A6p3.cpp ) that accepts one command line argument which is an integer n between 2 and 6

Write a C or C++ program A6p3.c (or A6p3.cpp) that accepts one command line argument which is an integer n between 2 and 6 inclusive. Generate a string of 60 random lower case English characters and store them somewhere (e.g. in a char array). Use pthread to create n threads to convert the string into all upper case. (You may call the toupper and tolower functions declared in ctype.h). You should divide this conversion task among the n threads as evenly as possible. Print out both the lower case and upper case version of the string in separate lines. That is, 60 lower case English characters on one line and 60 corresponding upper case English characters on another line. (Hint: it is dangerous to include printing code in your thread function(s).) You may refer to testThread.c, testThread2.c, pthread_ex1.c, pthread_ex2.c for example codes. (35 points) (Note: if you do not use pthread to divide the conversion task among the threads, you may get zero points.) A sample run of the program is shown below. You do NOT need to submit screen shots. Instead submit your source file.

image text in transcribed

kwang@talon-sub2.local][~/work/templ$ A6p3 4 using 4 threads original lower case version: guaxfrormnyqljridxblzihyvlpejswpmxmrqcicrhvdsmlvlohkyqktbaam upper case version: GUAXFRORMNYQLJRIDXBLZIHYVLPEJSWPMXMRQCICRHVDSML VLOHKYQKTBAAM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions