Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (15 points) Write a C function with the following signature that gets three strings as input parameters: char* str, char* pattern and char* altPattern

1. (15 points) Write a C function with the following signature that gets three strings as input parameters: char* str, char* pattern and char* altPattern. Your function should searches for pattern in str and replaces all occurrences of pattern by altPattern and return the resulting string as its return value.

Please note that the function should not modify the content of the three char arrays passed to it as its input parameters while doing the mentioned task.

Hint: you may use malloc function to allocate memory for storing the string that your function returns.

char* findAndReplace(char* str, char* pattern, char* altPattern){

...

}

2. (10 points) Write a function that gets a variable of type int as its only input parameter and prints out the binary representation of the input integer. Our assumption is that the input parameter is always a non-negative integer.

3. (15 points) Given the following structure for node, write a function that gets the pointer to the head of a singly linked list (type: node*) as its only input parameter and returns the average of values stored in the list (return value type: double).

struct node{

int value;

struct node* next;

};

typedef struct node node;

(Focus on #3)

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

List the components of the strategic management process. page 77

Answered: 1 week ago