Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code a function to generate a string, s1, containing a random pattern of upper case letter A - Z. Cannot use library functions such as
Code a function to generate a string, s1, containing a random pattern of upper case letter A - Z.
Cannot use library functions such as strlen, strcpy, etc.
a), a) c) and d) are in one program.
NOTE: No lbrary functions may be used in these programs except input and output functions such as getchar, putchar, gets, puts. LAB 4A Objective To gain experience in using arrays, strings, and functions. Problem definition Plan, code, and execute a C program to a) Code a function to generate a string containing a random pattem of upper case letters A' -Z: Length 40 characters). This will be string 1 b) Code a function to allow the user to enter a string containing a random pattern of upper case letters A -2 Minimum length 2 characters; maximum length 20 characters. Actual length is user's choice. This will be string 2 c) Code a user defined function, find, to find the index of the first character in string 2 that does not belong to the set of characters specified by string 1. The function arguments are the two strings. The null character terminating string I and string 2 is not to be considered in the matching process. If string 2 begins with a character not in string 1, the function returns a 0. For example: If string 1 is 'abab.: and string 2 is 'abcbedab', the function would return 2, the array index (position) of the first character in string 2 not in string 1. d) Output the generated string, the 'user entered string, and the position of the first character in string 2 not in string 1. Allow the user to enter multiple data sets. Use the original random string for all comparisons. Random String To create the generated pattern use the library function RAND which generates pseudorandom numbers from 0-32767. The modulus operator can be used to change the range to0-25. This should be done in a function. Generate the random string only once Remember: STRINGS MUST TERMINATE WITH 10 DO NOT USE POINTERS OR GLOBALS IN THIS LAB (4A). LAB 5A Obiective: To gain experience in the use of pointers. Problem definition Modify lab 4 by replacing all aray references wilh pointers references. You sill need array declarations and definitions. No subscripts in functions, USE ONLY PURE POINTER NOTATION
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started