
Create a new file (in Dev C++) and save it as lab11_XYZ.cpp (replace XYZ with your initials).
Create ANOTHER new file (in Dev C++) and save it as swap_XYZ.h (replace XYZ with your initials).
Use the swap_XYZ.h header file to define a set of functions for swapping two items of the same type.
Given the following prototypes, define (overloaded) swap functions
- void swap(int&, int&); //swap two integers
- void swap(double&, double&); //swap two doubles
- void swap(float&, float&); //swap two floats
- void swap(char&, char&); //swap two characters
- void swap(string&, string&); //swap two strings
The header file should contain the following:
- header comments (similar to normal
program header comments) - function definitions (for you to do, based on provided prototypes above...)
In general, a swap works like this:
void swap(type first&, type second&){ type temp = first; first = second; second = temp;
}
Once your header file is complete, make sure to include it in your main CPP program. Use double quotes instead of angle brackets. Make sure the header file (H file) is located in the same folder as the CPP file.
#include <iostream>#include "swap_XYZ.h"
using namespace std;
Write a driver program to test your header file. The program should test each version of the swap function and display the results.
The program should:
- display a hello message consider using displayMessage()!
- for each version of swap(),
- provide or prompt for two items consider using prompt()!
- display which version is being called
- display values before swap
- call swap function
- display values after swap
- display a goodbye message use displayMessage() again!
Language is C++
Please make it as simple as possible!

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- Write a function getQuestions that accepts a single parameter: filename, which is the name of a txt file. Your function should assume that the text file is formatted in the following way, as a series of questions and answers, with a question on one line, and the answer to the question on the following line, as below ---Sample File--- Why is the sky blue? Because air is blue. How long does it take light to reach Earth from the Sun? About eight minutes. What is the dumbest question you've ever been asked? That one. ---End Sample File--- Your function should create and return a dictionary where the keys are the questions and the values are respective answers (so the above sample file would result in a dictionary with three key-value pairs, one per question).arrow_forwardFileAttributes.c 1. Create a new C source code file named FileAttributes.c preprocessor 2. Include the following C libraries a. stdio.h b. stdlib.h c. time.h d. string.h e. dirent.h f. sys/stat.h 3. Function prototype for function printAttributes() main() 4. Write the main function to do the following a. Return type int b. Empty parameter list c. Declare a variable of data type struct stat to store the attribute structure (i.e. statBuff) d. Declare a variable of data type int to store an error code (i.e. err) e. Declare a variable of data type struct dirent as a pointer (i.e. de) f. Declare a variable of data type DIR as a pointer set equal to function call opendir() passing explicit text “.” as an argument to indicate the current directory (i.e. dr) g. If the DIR variable is equal to NULL do the following i. Output to the…arrow_forwardWrite a C++ program to do the following: Read the attached file ("TextFile.txt") and the count the number of times each alphabetic letter is used. Do not count punctuation, whitespace, or numbers. Only count letters a-z. When counting, treat lower and upper case characters the same. Use the attached CPP program as a guide to manage the counting. Use the structure and array provided to maintain counts. See examples in the program. When the all processing is completed, display the total for all letter counts. Example Output Below.: This numbers below are not intended to be accurate. No special formatting required but should be readable. A: 103 B: 15 C: 22... // remaining lettersZ: 4 cpp code: #include "stdafx.h" #include <iostream> using namespace std; struct LetterCount { char letter; int count; }; // declare an array of structure const int MAXLETTERS = 26; LetterCount myLetterCount[MAXLETTERS]; int main() { // initialize - MOVE THIS TO A METHOD for…arrow_forward
- in c with commentsarrow_forwardpls code in pythonplagiarism: This Boolean function takes two filenames. If any line occurs in both files, return True.If not, return False. I suggest using nested loops. With nested loops, we call the loop that is in thebody of the other loop, the "inner loop". The loop that contains the inner loop is the "outer loop". Openthe second file inside the outer loop:for line1 in file1:file2 = open(fname2)for line2 in file2:Python only lets you read the file once per open, so you need this order of instructions. Make sure yourreturn False is outside of both loops. Otherwise, you will only compare the first two lines of thefiles. Make sure you close the file that gets read repeatedly after the inner loop but still inside the outerloop.Here is some (more complete) pseudocode to get you started:open file 1for line1 in file 1open file 2for line2 in file 2:if line1 == line2:return Trueclose file 2return Falsearrow_forwardI need help on my python assignment.arrow_forward
- Write a C code to take input from an input .txt file and write into an output file. The input file should have int type values and the output file should contain the square of each inputfrom the input file. Must use file type pointers implementation. A sample input and output are given as follows:Input:1 2 3 4 5Output:1 4 9 16 25arrow_forwardWrite a function in python named "read_words" that declares a parameter for a filename and returns a collection of unique words in the file. Even though words.txt contains a single word per line, you should not assume that this is true of every file. For example, if the line is a sentence, you should split the line into individual words before storing each word in your collection. Handle any errors that occur by printing a detailed error message. Hint: the Python set works like Java's HashSet.arrow_forwardwrite the code in C++arrow_forward
- Write a Python function ‘AVGCSV’ that reads a .csv file that includes ‘n’ rows and ‘m’ columns, it calculates the average of each row and writes it at the end of the row, and it calculates the average of each column and writes it at the end of the column. The function should modify the .csv file and save it after adding all the averages.arrow_forwardCreate the following in C++arrow_forwardin C program pleasearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





