C++ Arithmetic Operations Exercises
C++ Arithmetic Operations Exercises
VIRTUAL MODE
NOVEMBER 1, 2021
2
TABLE OF CONTENTS
INTRODUCTION................................................................................................................................3
OBJECTIVES........................................................................................................................................4
General............................................................................................................................................4
Specific.....................................................................................................................................4
FIRST EXERCISE5
Program in C++ language5
Program result (compile and run)......................................................................6
SECOND EXERCISE....................................................................................................................7
Program in C++ language7
Program result (compile and execute)8
THIRD EXERCISE.
Program in C++ language.........................................................................................................9
Program result (compile and run)
FOURTH EXERCISE......................................................................................................................11
Analysis of program results12
Program result (compile and run)....................................................................13
conclusions14
BIBLIOGRAPHY15
3
INTRODUCTION
basics of the C++ language, and through specific examples will be developed
programs through a C++ language compiler and in turn, we will be able to correct
possible errors that may arise in given instructions or programs.
4
OBJECTIVES
General
Specific
FIRST EXERCISE
x=8+2*5/2-1
x = 8 + 10 / 2 - 1
x= 8 + 5 - 1
x = 13 - 1
x = 12
#include <cstdio>
#include <conio.h>
#include <iostream>
getch();
return 0;
}
6
SECOND EXERCISE
x = (4 * 8 * (4 + (8 * 4 / (3))))
x = (4 * 8 * (4 + (32 / 3)))
x = (4 * 8 * (4 + (32 / 3)))
x = (4 * 8 * (4 + 10.66666667))
x= (4 * 8 * 14.66666667)
x= 469.333
#include <cstdio>
#include <conio.h>
#include <iostream>
float x;
cout << "Welcome, I will help you find the value of x.\n";
x = (4.0 * 8.0 * (4.0 + (8.0 * 4.0 / (3.0))));
getch ();
return 0;
}
8
THIRD EXERCISE
x = 4 + 5 * (9 * (5 - (8 + 4) / 6))
x = 4 + 5 * (9 * (5 - 12 / 6))
x = 4 + 5 * (9 * 3)
X = 4 + 5 * 27
X = 4 + 135
X= 139
#include <cstdio>
#include <conio.h>
#include <iostream>
float x;
getch ();
return 0;
}
10
FOURTH EXERCISE
//cin>>name;
They are found as comment lines within the program. The lines that start
with two slash signs are considered comments and have no effect on the
program behavior (Flores, 2008).
However, at the time of removing these slash signs from the instructions of
program given in the exercise, we can see that the program runs with more
success, allowing the user to enter the requested data, in this case the name of the
user.
Correction of instructions
#include<iostream>
int main ()
string name;
AREANDINA
}
13
CONCLUSIONS
BIBLIOGRAPHY