give me some programs in java to use different types of operators .
Answers
Answered by
2
some programs of java are :-
on operators
/* program to add three numbers */
public class addnum
{
public static void main(string arg [])
{
int num1 = 20
int num2 = 30
int num3 = 40
int tot;
tot = num1 + num2 + num3 ;
system.out.printIn("total of + num1 +"and" + num2 +"and"+num3+"is"+tot);
}
}
control flow statements
program to display table of 3 using for loop
public class table of3
{
public satic void main(string arg [])
{
int i,j;
for (i = 1 ; <= 10;i++)
{
j = 3 * i;
system.out.printIn("3*"+i+"="+j);
}
}
}
on operators
/* program to add three numbers */
public class addnum
{
public static void main(string arg [])
{
int num1 = 20
int num2 = 30
int num3 = 40
int tot;
tot = num1 + num2 + num3 ;
system.out.printIn("total of + num1 +"and" + num2 +"and"+num3+"is"+tot);
}
}
control flow statements
program to display table of 3 using for loop
public class table of3
{
public satic void main(string arg [])
{
int i,j;
for (i = 1 ; <= 10;i++)
{
j = 3 * i;
system.out.printIn("3*"+i+"="+j);
}
}
}
kvnmurty:
it is not clear, which operators have you used ? please list them.
Answered by
0
/* to Write a program to Concatenate string using for Loop
Example:
Input - 4
Output - 1 2 3 4 */
class Join{
public static void main(String args[]){
int num = Integer.parseInt(args[0]);
String result = " ";
for(int i=1;i<=num;i++){
result = result + i + " ";
}
System.out.println(result);
}
Example:
Input - 4
Output - 1 2 3 4 */
class Join{
public static void main(String args[]){
int num = Integer.parseInt(args[0]);
String result = " ";
for(int i=1;i<=num;i++){
result = result + i + " ";
}
System.out.println(result);
}
Similar questions