Answer:
// here is code in C++.
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int x=5,y=2,z=9;
int min;
// find the smallest value and assign to min
// if x is smallest
if(x < y && x < z)
// assign x to min
min=x;
// if y is smallest
else if(y < z)
// assign y to min
min=y;
// if z is smallest
else
// assign z to min
min=z;
// print the smallest
cout<<"smallest value is:"<<min<<endl;
return 0;
}
Explanation:
Declare and initialize variables x=5,y=2 and z=9.Then check if x is less than y and x is less than z, assign value of x to variable "min" .Else if value of y is less than value of z then smallest value is y, assign value of y to "min".Else z will be the smallest value, assign its value to "min".
Output:
smallest value is:2
The correct answer I believe is A Sex offender
Answer:
The program to this question can be given as follows:
Program:
public class data //defining class data
{
//main method
public static void main (String [] as) //declaring main method
{
int userNum = 4; //declare variable userNum and assign value
for (userNum = 1; userNum <= 4; userNum++) //loop for print values
{
System.out.println(userNum); //print values in new lines.
}
}
}
Output:
1
2
3
4
Explanation:
In the above java program code firstly a class "data" is defined, inside this class the main method is defined in which an integer variable userNum is defined that holds a value that is "4".
- In this method, a for loop is declare that uses variable userNum which starts from 1 and ends with a given value that is equal to 4.
- Inside a for loop, the print function is used that print userNum variable each values in the newline.