CODE: ( Compiled using Code::Blocks)
1. fun.cpp
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
string echo(string input = "echo"){
return input;
}
string echo(string input,int num){
string result;
if(num%2==0){
stringstream stm;
stm << input
<< num;
result =
stm.str();
}else{
stringstream stm;
stm << num
<< input;
result =
stm.str();
}
return result;
}
int main()
{
ifstream infile("values.txt");
string line;
int linenumber = 0;
if(infile.is_open()){
while (getline(infile,
line))
{
cout<<echo(line)<<endl;
cout<<echo(line,linenumber)<<endl;
linenumber++;
}
infile.close();
}
}
2. Makefile ( Generated by cbp2make):
WORKDIR = %cd%
CC = gcc.exe
CXX = g++.exe
AR = ar.exe
LD = g++.exe
WINDRES = windres.exe
INC =
CFLAGS = -Wall -fexceptions
RESINC =
LIBDIR =
LIB =
LDFLAGS =
INC_DEBUG = $(INC)
CFLAGS_DEBUG = $(CFLAGS) -g
RESINC_DEBUG = $(RESINC)
RCFLAGS_DEBUG = $(RCFLAGS)
LIBDIR_DEBUG = $(LIBDIR)
LIB_DEBUG = $(LIB)
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = obj\\Debug
DEP_DEBUG =
OUT_DEBUG = bin\\Debug\\echoo.exe
INC_RELEASE = $(INC)
CFLAGS_RELEASE = $(CFLAGS) -O2
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB)
LDFLAGS_RELEASE = $(LDFLAGS) -s
OBJDIR_RELEASE = obj\\Release
DEP_RELEASE =
OUT_RELEASE = bin\\Release\\echoo.exe
OBJ_DEBUG = $(OBJDIR_DEBUG)\\main.o
OBJ_RELEASE = $(OBJDIR_RELEASE)\\main.o
all: debug release
clean: clean_debug clean_release
before_debug:
cmd /c if not exist bin\\Debug md bin\\Debug
cmd /c if not exist $(OBJDIR_DEBUG) md
$(OBJDIR_DEBUG)
after_debug:
debug: before_debug out_debug after_debug
out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
$(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG)
$(LDFLAGS_DEBUG) $(LIB_DEBUG)
$(OBJDIR_DEBUG)\\main.o: main.cpp
$(CXX) $(CFLAGS_DEBUG) $(INC_DEBUG) -c main.cpp -o
$(OBJDIR_DEBUG)\\main.o
clean_debug:
cmd /c del /f $(OBJ_DEBUG) $(OUT_DEBUG)
cmd /c rd bin\\Debug
cmd /c rd $(OBJDIR_DEBUG)
before_release:
cmd /c if not exist bin\\Release md bin\\Release
cmd /c if not exist $(OBJDIR_RELEASE) md
$(OBJDIR_RELEASE)
after_release:
release: before_release out_release after_release
out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
$(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE)
$(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)
$(OBJDIR_RELEASE)\\main.o: main.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cpp -o
$(OBJDIR_RELEASE)\\main.o
clean_release:
cmd /c del /f $(OBJ_RELEASE) $(OUT_RELEASE)
cmd /c rd bin\\Release
cmd /c rd $(OBJDIR_RELEASE)
.PHONY: before_debug after_debug clean_debug before_release after_release clean_release
OUTPUT:
For this activity, you are required to provide files called fun.cpp as well as a makefile to comp...
C++ 2.3 Activity 3: Bubble Sort For this activity, you are required to provide files called act3.cpp as well as a makefile to compile and run it. In your file, act3.cpp, should have a skeleton of a main program as per normal which you will then fill it in as per the following. The objective of this activity is to demonstrate the bubble sort algorithm for arrays. You are going to implement this as a function with the following definition:...
Programming languages allow the programmer to create his or her own functions which are called __________ __________ functions. The function that returns the number of characters in a string is the __________ function. __________ files contain records that must be processed in the order in which they were created. The elements of an array are stored in __________ storage locations in the computer’s memory. A variable that is declared outside all program modules, including the main module, has __________ scope....
Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors. Create Functions, include headers and other files, Loops(while, for), conditional(if, switch), datatypes, etc. Assignment You work at the computer science library, and your boss just bought a bunch of new books for the library! All of the new books need to be cataloged and sorted back on the shelf. You don’t need to keep track of which customer has the book or not, just whether...
C++ Project You should be comfortable with the content in the modules up to and including the module "Input Output" for this project. For this project, download the text file weblog.txt. Note: To download this file, right click on the link and select SAVE AS This file is an Apache web log taken from the web server for St. Mary's University. When a visitor goes to their web site, the visitor's browser makes a request to the web server to...
In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main() function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the string that the function...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of amain () function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main() function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the...
You will be reading in 3 files in the program. One will contain a list of 1000 words in unsorted order. The second file will contain 1000 words in sorted order. The final file will contain 20 words to be searched for. The main program has been written for you. You will be implementing three functions: bool readWords(string array[], int size, string fileName); int linearSearch(string wordToFind, const string words[], int size); int binarySearch(string wordToFind, const string words[], int size); The...
In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....
There is a file called mat2.txt in our files area under the Assignments folder. Download it and save it in the same folder where this Matlab file (HW08_02.m) is saved. It may be worth opening that text file to see how it is set out. Note well, however, that the file might have a different number of lines and different number of numbers on each line. Write a Matlab program that does the following: Prompt the user for an input...