Arithematic operators Program

December 28, 2019

Simple program for performing Arithmetic operation



First we see what does Arithmetic Operator mean?

        Arithmetic operator is a mathematical function  that takes two inputs and performs a calculation on them. They are used in common arithmetic and most computer languages contain a set of such operators that can be used within equations to perform a number of types of sequential calculation. Basic arithmetic operators include:
  • Addition (+): It displays the addition of two numbers. Eg. 4+6=10
  • Subtraction (-):It performs the subtraction of two numbers. Eg.5-2=3
  • Multiplication (×):It performs the Multiplication of two numbers. Eg.5*7=35
  • Division (÷):It performs the Division of two numbers. Eg. 6/2=3
  • Modula(%):It displays the remainders. Eg. 6%4=2
     Computers use different symbols in programming to represent multiplication (*) and division (/). More complex operators such as square root (√) also act as arithmetic operators but the basic plus, minus, multiply and divide are the fundamental operators.

C language code for addition, subtraction, multiplication, division and modulo:

#include<studio.h>
#include<condo.h>
float main ()
{
float a, b,add, sub, mul, div, rem;
closcr();
printf ("ENTER THE TWO NUMBERS TO FIND THE ADDITION ,SUBTRACTION, MULTIPLICATION, DIVISION, REMAINDER\n");
scanf ("%f%f",&a&b);
add=a+b;
sub=a-b;
mul=a×b;
div=a/b;
rem=a%b;
printf ("ADDITION=%f\n", add);
printf ("SUBTRACTION=%f\n", sub);
printf ("MULTIPLICATION=%f\n", mul);
printf ("DIVISION=%f\n", div);
printf ("REMAINDER=%f\n", rem);
getch();
return();
}
                Friends in this code we perform all operations. If we use floating points then it accepts the integers also, so better way use float points.
                In this code clrscr() is new concept.It means that the previous output is clear. Try it automatically you learn.
The following images show the actual code and output screen.

                This is the input screen I.e.coding screen.




              This Window shows that there is no error in the code.

              This is the final output screen with example.

              Friends such information I was typing on mobile so remainder operations are not possible but on the latest version it did or on the computer it did easily.
              If any query is there then write in the comment box.Thank you...
     




Arithematic operators Program Arithematic operators Program Reviewed by Amit Waghmare on December 28, 2019 Rating: 5

Reverse String

December 26, 2019



                           Java Program to print the Reverse String

In this blog we the java program to reverse the given string. To reverse the given string we use two variables i.e. original, reverse and reverse a string is initialized as null. Then by using a scanner, we scan the input string. This input string is stored in the original variable. Then by using length function and for loop program will reverse the string and finally stored in the reverse string. The actual code is as follows.
Code:
import java.util.*;
class ReverseString
{
public static void main(String args[])
 {
 String original,reverse="";
 Scanner in=new Scanner(System.in);
 System.out.print("Enter a string to be reverse:");
 original=in.nextLine();
 int length=original.length();
 for(int i=length-1;i>=0;i--)
  {
  reverse=reverse+original.charAt(i);
  }
 System.out.println("Reverse of entered string:"+reverse);
 }
}
Output:
C:\jp> javac ReverseString.java
C:\jp> java ReverseString
Enter a string to be reverse:TutorialLands
Reverse of entered string:sdnaLlairotuT
C:\jp>




Reverse String Reverse String Reviewed by Amit Waghmare on December 26, 2019 Rating: 5

Java Half Pyramid Pattern

December 09, 2019



Java Program to Print half inverted Pyramid

       Hello friends, In this post, we see the simple java code to print the above pattern. To print the pattern we use 2 for loop, first for rows and second for columns. 
       We initialize two variables i.e. i and j as an integer, i for Row and j for column. The difference between the keyword print and println is, print is use to print the data/statement, as well as the second data/statement is print in front of first line. For example,
Code:
class print_printlnDemo
{
public static void main(String args[])
{
System.out.print("Java ");
System.out.print("Programming ");
System.out.print("Softwere");
}
}
Output:
 
       Println is use to print the data/statement, as well as the second data/statement is print at next line. For example,  
Code:
class print_printlnDemo
{
public static void main(String args[])
{
System.out.print("Java ");
System.out.println("Programming ");
System.out.println("Softwere");
}
}
Output:

Java Program to Print half inverted Pyramid
Program:
class DisplayPattern
{
public static void main(String args[])
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=i;j<=5;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}

Output:


Java Half Pyramid Pattern Java Half Pyramid Pattern Reviewed by Amit Waghmare on December 09, 2019 Rating: 5

Simple Java Program

December 06, 2019

Java Programming

                      Hello friends, In this blog, we see how to run the Java program. It is very simple to run the java program. To run the java code your machine must have a JDK (Java Development KIT) file. When you install it on your pc one folder named as Java is created in c drive. So, first of all, we see the simple java program to display "Hello I am Java Programmer". I will explain every stapes of the program.

Program:
class intro
{
public static void main(String args[])
{
System.out.println("Hello I am Java Programmer");
}
}
            To run the program there are two stapes in that First is Compilation and second is Interpretation.

Compilation: A compilation is one type of application softwere that translates or converts the code from human-readable code to machine-readable code i.e. in the form of 0 and 1. To make this conversion successful we must write a code on the notepad and save this code with extension .java. When we compile this code on command prompt, one same name file is created with extension .class and this file is in machine-readable form.
            To compile the java code the class name and file name must same. And to compile the code on command prompt type javac intro.java

Interpretation: Interpretation means the actual execution of the program, Once we successfully compile the program we can execute it easily. To run the java program on command prompt type java class_name i.e. java intro


Stapes to run the java program:
 Step 1: Go to that folder where your java code to be saved using the command prompt.
Step 2: Set the JDK path as shown below,



Step 3: Compile the java program using syntax javac class_name.java
      (For example, javac intro.java)


Step 4: Finally to run or execute the code type java class_name


Note: In syntax, I wrote class_name which is the same as the file name.

Output:


Simple Java Program Simple Java Program Reviewed by Amit Waghmare on December 06, 2019 Rating: 5