Select the correct answer.
6.41
5.41
5.409
5.411
Solution
1)Find the partial sumof the seriesrounded to the nearest thousandth. Question 7 options: n
an=5/4^n sum 1 1.2500 1.2500 2 0.3125 1.5625 3 0.0781 1.6406 4 0.0195 1.6602 5 0.0049
1.6650 6 0.0012 1.6663 7 0.0003 1.6666 8 0.0001 1.6666 9 0.0000 1.6667 10 0.0000 1.6667 11
0.0000 1.6667 none of answers fit 1.667 2)Given the series: and. Determine whether each
series is convergent or divergent. Question 8 options: a) converges because cos ^2(10n)is greater
than or equal to zero and less than 1 so series a is 1 so it converges and so does a b diverges
because cos is greater than or equal to -1 and less than or equal to 1, which does not converge to
0, so b diverges ans Ais convergent,Bis divergent. 3)Determine whether the series converges
or diverges. NO SERIES Select the correct answer. Question 9 options: neither diverges
converges 4)Determine whether the sequence converges or diverges. diverges because n(n-6)
goes to infinity as n goes to infinity Question 10 options: converges diverges.
The code in image3.cpp has the error as shown above, could you help .pdf
1. The code in image3.cpp has the error as shown above, could you help me fix them. Thank you.
image3.cpp
#include
#include
#include "image3.hpp"
using namespace std;
/*
ERROR CODES:
-1 : Malloc function not working properly.
-2 : Out Of Scope Pixel.
-3 : File that you are trying to open cannot be opened due to some reason.
*/
/* Constructs an image of 0x0 pixels. */
Image::Image() {
cols=0;
rows=0;
pixels=NULL;
}
/* Frees all memory allocated for img */
Image::~Image() {
cols=0;
rows=0;
delete pixels;
}
/* Changes the size of an image, allocating memory as necessary, and setting all pixels to
fillcolor.
Returns 0 on success, or a non-zero error code.*/
int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) {
/*Width of the image is stored in columns.
Height of the image is stored in rows.*/
cols=width;
rows=height;
pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
2. }
for(int i=0; i=cols || y>=rows) {
return -2;
} else {
pixels[x][y]=color;
return 0;
}
}
/* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp.
Returns 0 on success, else a non-zero error code. */
int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) {
if(x>=cols || y>=rows) {
return -2;
} else {
*colorp=pixels[x][y];
return 0;
}
}
/* Saves the image in the file filename. In a format that can be loaded by load().
Returns 0 on success, else a non-zero error code. */
int Image::save(const char* filename) {
ofstream OutputFile(filename);
if(OutputFile.is_open()) {
OutputFile<>input;
if(!ColsAssignment) {
cols=input;
ColsAssignment = true;
} else if(!RowsAssignment) {
rows=input;
RowsAssignment = true;
} else {
if(!PixelsDeclaration) {
pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
3. for(int i=0; i // for uint8_t
class Image {
public:
unsigned int cols;
unsigned int rows;
uint8_t** pixels;
/* Constructs an image of 0x0 pixels. */
Image();
/* Frees all memory allocated for img */
~Image();
/* Changes the size of an image, allocating memory as necessary, and
setting all pixels to fillcolor. Returns 0 on success, or a
non-zero error code.*/
int resize( unsigned int width, unsigned int height, uint8_t fillcolor );
/* Sets the color of the pixel at (x,y) to color. Returns 0 on
success, else a non-zero error code. If (x,y) is not a valid
pixel, the call fails and the image does not change.*/
int set_pixel( unsigned int x, unsigned int y, uint8_t color );
/* Gets the color of the pixel at (x,y) and stores at the address
pointed to by colorp. Returns 0 on success, else a non-zero error
code. */
int get_pixel( unsigned int x, unsigned int y, uint8_t* colorp );
/* Saves the image in the file filename. In a format that can be
loaded by load(). Returns 0 on success, else a non-zero error
code. */
int save( const char* filename );
/* Load the an image from the file filename, replacing the current
image size and data. The file is in a format that was saved by
save(). Returns 0 success, else a non-zero error code . */
4. int load( const char* filename );
}; Make dout cp LAB/image 3.hpp cp LAB/test 3.cpp cp REPO/image 3.cpp g++ -Wall -o t3
test 3.cpp image3.cpp Make stderr: test 3.cpp: In function a€ int main()a€"": test3.cpp 198:21:
warning comparison between signed and unsigned integer expressions [-Wsign-compare]
test3.cpp 199:23: warning comparison between signed and unsigned intege r expressions I-
Wsign-compare] test3.cpp 222:21: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare] image3.cpp: In member function int Image: resize (unsigned int
unsigned int uint8 t)a€"": image3.cpp: 38:20: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare image3.cpp:43:24: warning: comparison between
signed and unsigned integer expressions I-Wsign-compare] image3.cpp: In member function int
Image save (const char*) a€ image3.cpp:78:24: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare image3.cpp:79:28: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare] image3.cpp: In member function int
Image: :load (const char*)€": image3.cpp 118:36: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare] image3.cpp: 124:28: warning: name lookup of
ia€" changed lenabled by default] image 3.cpp: 103:13: warning matches this i€T under old
rules lenabled by default] de image 3.cpp: 118:29: warning image3 .cpp: 103:22: warning:
unused variable a€ ka€" [-Wunused-variable /tmp/ccfZ2udV.o: In function main' image3 .cpp:
(.text+0x7a8) multiple definition of main /tmp/ccpXXxQE.o:test3.cpp: (.text+0x0) first defined
here collect2: ld returned 1 exit status make [t3] Error 1 Build failed
Solution
There is multiple Definition of main () { } , Empty implementation in image3.cpp
One in test3.cpp and the other in image3.cpp . Since main () of image3.cpp is empty remove that
. I have pasted the same code by removing int main () { }
#include
#include
#include "image3.hpp"
using namespace std;
/*
ERROR CODES:
-1 : Malloc function not working properly.
-2 : Out Of Scope Pixel.
-3 : File that you are trying to open cannot be opened due to some reason.
*/
5. /* Constructs an image of 0x0 pixels. */
Image::Image() {
cols=0;
rows=0;
pixels=NULL;
}
/* Frees all memory allocated for img */
Image::~Image() {
cols=0;
rows=0;
delete pixels;
}
/* Changes the size of an image, allocating memory as necessary, and setting all pixels to
fillcolor.
Returns 0 on success, or a non-zero error code.*/
int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) {
/*Width of the image is stored in columns.
Height of the image is stored in rows.*/
cols=width;
rows=height;
pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i=cols || y>=rows) {
return -2;
} else {
pixels[x][y]=color;
return 0;
}
}
/* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp.
Returns 0 on success, else a non-zero error code. */
int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) {
if(x>=cols || y>=rows) {
return -2;
6. } else {
*colorp=pixels[x][y];
return 0;
}
}
/* Saves the image in the file filename. In a format that can be loaded by load().
Returns 0 on success, else a non-zero error code. */
int Image::save(const char* filename) {
ofstream OutputFile(filename);
if(OutputFile.is_open()) {
OutputFile<>input;
if(!ColsAssignment) {
cols=input;
ColsAssignment = true;
} else if(!RowsAssignment) {
rows=input;
RowsAssignment = true;
} else {
if(!PixelsDeclaration) {
pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i