'Program that will have the user input [closed]
package state;
import java.util. Scanner;
public class State {
emphasized text enter code herestrong text //create a program with a user inputstrong text public static void main(String[] args) { Scanner tuwa1 = new Scanner(System.in); System.out.println("Enter Number"); //User input callMyself(10); } /* The recursive Java method */ public static void callMyself(long i) { if (i < 0) { return; } System.out.print(i); i = i - 1; callMyself(i);
int number1 = tuwa1.nexInt();
System.out.println()
}
}
Solution 1:[1]
The program
#include <iostream>
int main()
{
int a = 1, b = 2, c = 3;
std::cout <<
"The values of the variables are " <<
a << ", " << b << " and " << c << ".\n";
return 0;
}
will print all three variables in a single line of output, using only a single statement. The output will be the following:
The values of the variables are 1, 2 and 3.
The statement
std::cout <<
"The values of the variables are " <<
a << ", " << b << " and " << c << ".\n";
can also be written as a single line, if that is a requirement of your exercise.
std::cout << "The values of the variables are " << a << ", " << b << " and " << c << ".\n";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
