Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Java8 Online

public class HelloWorld{

     public static void main(String []args){
        System.out.println("Hello World");
     }
}

Compile and Execute C Online

c

#include <stdio.h>
char findMSB(int number)
{
    char msb = 0;
    int sizeInBits = 0;
    sizeInBits = sizeof(number)*8;
    
    for(char iii =0;iii<sizeInBits;iii++)
    {
        ((number>>iii)&1)?(msb = iii):NULL; 
    }
    printf("msb is %d\n",msb);
    return msb;
}

char ifAlternate(char msb,int number)
{
    char lsb = 0,isAlternate = 1;
    (number&1)?(lsb = 1):(lsb=0);
    char valueOfBit = 0;
    for(char iii = 0;iii<=msb;iii++)
    {
        
        valueOfBit = (number>>iii)&1;
        printf("\nvalueof bit is %d\n",valueOfBit);
        if((iii%2 == 0)&&(valueOfBit==lsb))
            continue;
        else if((iii%2 != 0)&&(valueOfBit!=lsb))
            continue;
        else 
        {
            isAlternate = 0;
            break;
        }   
    }
    (isAlternate == 1)?printf("\nis alternate\n"):printf("\ni not alternate\n");
    return isAlternate;
}
int main()
{
     int number;
     char msb = 0,isAlternate =0;
     scanf("%d",&number);
     msb = findMSB(number);
     isAlternate = ifAlternate (msb,number); 
    return 0;
}

Compile and Execute Java Online

public class HelloWorld{

    static class Player{
        String name;
        int hp;
        int atk;
        
        public Player(String name, int hp, int atk){
            this.name = name;
            this.hp = hp;
            this.atk = atk;
        }
        public void attack(Enemy enemy){
            System.out.println("Enemy Attack!");
            enemy.hp -= this.atk;
            System.out.println("Enemy hp :"+enemy.hp);
        }
        public boolean isLive(){
            if(hp <= 0){
                return false;
            }else{
                return true;
            }
        }
    }
    
    static class Enemy{
        String name;
        int hp;
        int atk;
        
        public Enemy(String name, int hp, int atk){
            this.name = name;
            this.hp = hp;
            this.atk = atk;
        }
        public void attack(Player player){
            System.out.println("Player Attack!");
            player.hp -= this.atk;
            System.out.println("Player hp :"+player.hp);
        }
        public boolean isLive(){
            if(hp <= 0){
                return false;
            }else{
                return true;
            }
        }
    }

     public static void main(String []args){
        
        Player player = new Player("gampari", 100, 12);
        Enemy enemy = new Enemy("Orc", 80, 5);
        
        while(player.isLive() && enemy.isLive()){
            player.attack(enemy);
            if(!enemy.isLive()) break;
            enemy.attack(player);
        }
        
        if(player.isLive()){
            System.out.println("player win");
        }else{
            System.out.println("enemy win");
        }
     }
}

Execute Bash Shell Online

# Hello World Program in Bash Shell
#! /bin/bash
echo "Hello World!"
echo 'THIS IS VERY NICE TO LEARN THE THINGS IN ONLINE'
echo 'Enter the name'
rac=Satya
echo "entered name is $rac "
unset rac
echo "entered name is $rac "
echo $$

satya_shell_future_benifits

# Hello World Program in Bash Shell
#! /bin/bash
echo "Hello World!"
echo 'THIS IS VERY NICE TO LEARN THE THINGS IN ONLINE'
echo 'Enter the name'
rac=Satya
echo "entered name is $rac "
unset rac
echo "entered name is $rac "
echo $$

Compile and Execute C++ Online

cpp

#include<iostream>
using namespace std;

double getUnitprice(int itemCode);

int main(){

  double invoice[10][4];
  int i=0; char more; char date[100];

  cout << "\n\n********* Here are the Item prices for your information********** \n\nItem code\tUnitPrice\n\n1\t100\n2\t200\n3\t300\nInvalidCode\t0\n\n";
  cout << "Enter the date: ";
  cin >> date;
  
  do {
 
    cout << "\n\nItem code: ";
    cin >> invoice[i][0];
    cout << "Quantity : ";
    cin >> invoice[i][1];
    
    invoice[i][2] = getUnitprice(invoice[i][0]); 
    invoice[i][3] = invoice[i][1] * invoice[i][2]; 
    
    cout << "Do you have any other items to be entered next (y/n) ? ";
    cin >> more;
  
    i++;
  } while(more == 'y');
    
 
  cout << "\n\n-----------------------------\n\n";
  cout << "Date : " << date << "\n\n";
  
  cout << "ItemCode|Quantity|UnitPrice|TotalPrice\n\n";
  int tot=0;
  for(int k=0; k<i; k++)   
    
	{
		for(int l=0; l<4; l++) 
		{
		    cout << invoice[k][l]  << "\t";		   
		}
		cout << endl;
		tot = tot + invoice[k][3];
	}

  cout << "\n\nTotal : " << tot;
  cout << "\n\n-----------------------------\n\n\n";
  
  return 0;
}

double getUnitprice(int itemCode){
  double price;
  switch (itemCode)
  {
    case 1: price = 100;
      break; 
    case 2: price = 200;
      break;
    case 3: price = 300;
      break;
    default: price = 0;
      break;
  }
  return price;
}

Compile and Execute Java Online

import java.util.Scanner;
public class HelloWorld{
    public static void main(String[] args) {
        System.out.println("Input first number : ");
        Scanner in = new Scanner (System.in);
        int n1 = in.nextInt();
        
        System.out.println("Input second number : ");
        int n2 = in.nextInt();
        int sum = n1 + n2;
        System.out.println ("sum =" +n1+n2);
    }
}

Online AngularJS Editor

<!doctype html>
<html ng-app="Shopping">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
  </head>
  <body>
    <div>
      <label>Name:</label>
      <input type="text" ng-model="yourName" placeholder="Enter a name here">
      <hr>
      <h1>Hello {{yourName}}!</h1>
    </div>
  </body>
</html>

Compile and Execute C Online

c

#include <stdio.h>

int main()
{
    int i;
    for(i=1;i++;i<=5)
    printf("Hello, World!\n");

    return 0;
}

Compile and Execute C Online

c

import java.util.Scanner;
public class Fibonacci
{
    public static void main(String args[])
    {
        System.out.println("Enter a number:");
        Scanner Scan=new Scanner(System.in);
        int n=Integer.parseInt(s.nextInt());
        int a=-1;
        int b=1;
        int c=0;
        System.out.println("The fibonacci series are:");
        for(i=1;i<=n;i++)
        {
            c=a+b;
            int temp=a;
            a=b;
            b=c;
            System.out.println(c);
        }
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.