Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C PROGRAM help Add and test a function swapStrings that will swap two strings. DO NOT use strcpy . The characters comprising the strings do

C PROGRAM help

Add and test a function swapStrings that will swap two strings.

DO NOT use strcpy. The characters comprising the strings do not need to be moved or changed in any way. Instead, the addresses pointed to by the string variables should be swapped.

#include

void swapIntegers(int *, int *);

int main(void) {

int num1 = 5, num2 = 10;

printf("Before the swap: num1 = %d and num2 = %d ", num1, num2);

swapIntegers(&num1, &num2);

printf("After the swap: num1 = %d and num2 = %d ", num1, num2);

return 0;

}

void swapIntegers(int *n1, int *n2) { /* passed and returned by using values of pointers */

int temp;

temp = *n1;

*n1 = *n2;

*n2 = temp;

}

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

please try to give correct answer 7 9 3 . .

Answered: 1 week ago

Question

What perspective or approach to talent would be appropriate?

Answered: 1 week ago

Question

What policies and practices for talent development are needed now?

Answered: 1 week ago