Robotics C++ Programming Assignment: Fundamentals and Concepts

Verified

Added on  2022/12/22

|5
|482
|24
Homework Assignment
AI Summary
This C++ assignment focuses on fundamental programming concepts within the context of robotics. The solution includes a program that takes an integer input and uses a modulus operator, if/else statements, and loops to produce different outputs based on whether the input is even or odd. The assignment also answers questions related to C++ syntax, variable declaration, and program output prediction. Furthermore, it covers topics like loop execution, function definitions, and conditional statements. The provided solution covers different aspects of C++ programming and provides a solid foundation in understanding how to write and debug code for robotics applications. This assignment is a valuable resource for students learning C++ and robotics concepts, offering practical examples and solutions to enhance their understanding of these subjects.
Document Page
Running head: ROBOTICS C++ 1
Robotics C++
Name of Student
Institution Affiliation
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
ROBOTICS C++ 2
Part 1
#include <iostream> // Library for input/output
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int main( ) {
int input, remainder; // Declare two interger number
cout<<"Please enter a whole number:"; // Output prompt
cin>>input;
remainder=input%2; //Use modulus function
cout<<"The remander is: "<<endl;
//Do two things based on the integer being
//if/else statement
int i; //create a new loop control variable
if(remainder=0)//if an input is an even number (Check remainder)
{
i=input; //assign the loop control variable to input
while(i>=0) //Loop while i is greater than zero
{
cout<<i<<""; // Output the value of i
Document Page
ROBOTICS C++ 3
i--; //Decrement iusing the -- Operator
} //end of loop
} else //remeinder ==1, so its an odd number
{//Loop and output from 0 up to and include the input value
i=0;
while(i<input){
cout<<i<<""; //output value of i
i++;
}//End of loop
}//End else where remainder==1
cout<<"\n\n";
return 0;
}
Document Page
ROBOTICS C++ 4
Part 2,3 and 4 Solution to the Questions
1. <iostream> /
2. using namespace std;
3. int N=10;
4. double X=25.5;
5. N+=10;
6.
a. Invalid (values for x and y have neither been declared/initialised)
b. 23 23
c. 10 39
d. 10 39
e. Under d above the value of Y can only be incremented if the initial value which is
40 would have been less than predefined condition of 40. If the value of Y was
from 1 to 39 inclusive and also all the negative intergers.
7.
a. 100 times
b. 99 times
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
ROBOTICS C++ 5
8.
a. 17
b. 19.5
c. 1710/4
d. 16
9. The function computs and returns the largest integer from three sets of intenger values
10. If (y>=x){
Cout<<”Not good.\n Carry on”;
}
11. If (y>=x){
Cout<<”Not good.\n Carry on”;
}
12. If(((x/y)!=0) && (y!=0)) {
Cout<<x/y<<endl;
}
.
chevron_up_icon
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]