Tutorialspoint

Hello World Program in FORTRAN-95

program hello
   Print *, "Hello World!...4...."
end program Hello

Learning Constants, String and Structure in C

cpp

#include <iostream>
#include <sstream>
#include <cstring>
#include <ctime>
#include <unistd.h>
#define M 3
#define w 10
using namespace std;
string nomiferramenta[]={"scatolaDiChiodi","forbici","chiaveInglese","cacciavite","martello","nastroBiadesivo"};
string nomifarmacia[]={"aspirine","oki","sciroppoPerLaGola","brioski","cerotti","disinfettante"};
string nomifruttivendolo[]={"saccoDiPatate","radicchio","cetriolo","finocchio","pomodoro","casettaDiFragole"};
string nomiNegozioDiVestiti[]={"maglietta","felpa","pantaloni","gonna","cappello","giacca"};
string nomiNegoziodianimani[]={"parrocchetto","aski","carlino","cocorito","tartarugaD'acqua","geco"};
string nomi[]={"Marco","Giorgio","Astolfo","Daria","Anna","CicciaPanza"};
string nomic[]={"Ada","Gioia","Aurora","Tonia","Eva"};
double c=(rand()%10);
struct Cosa{
    string nome="nulla";
    int pos=c=(rand()%10);
    int q=0;
    double prezzo=c=(rand()%30);
};
struct  Persona{
    string nome;
    Cosa  oggetto;
    double soldi=100.0;
};

struct Negozio{
    string nome;
    Cosa cose[M];
    int N=M;
    Persona commessa;
};

void inizializzaNegozio(Negozio &neg, string nome){
    srand(time(0));
    string nomiN[7]{"Supermecato","Negoziodianimani","NegozioDiVestiti","NegozioDiGiocattoli","Farmacia","NegozioElettronica","Ferramenta"};
    string nomi[]={"Ada","Gioia","Aurora","Tonia","Eva"};
    neg.nome=nome=nomiN[rand()%7];
    neg.commessa.nome=nomi[rand()%5];
    stringstream ss;
    for(int i=0;i<neg.N;i++) {
        ss.str(""); ss<<"oggetto_"<< i;
        neg.cose[i].nome= ss.str();
        neg.cose[i].q=w+i;
    }
}
void preleva(Negozio &neg,int pos,int quant){
    if(neg.cose[pos].q >= quant) {
        neg.cose[pos].q -=quant;
    }else {
        neg.cose[pos].q=0;
        cout << "scorte non sufficienti!!!\n";
    }
}
void deposita(Negozio &neg,int pos,int quant){
    neg.cose[pos].q += quant;
}
void stampaNegozio(Negozio neg){
        cout<<neg.nome<<" gestita da "+neg.commessa.nome+" ha "<<neg.N<<" reparti:\n";
    for(int i=0;i<neg.N;i++)
        cout<<neg.cose[i].nome<<" con la quantita\' di "<< neg.cose[i].q<<"\n";
}

void gestioneNegozio(Negozio &neg,string nome){
    inizializzaNegozio(neg, nome);
    stampaNegozio(neg);
    preleva(neg,2,5);
    deposita(neg,0,7);
    stampaNegozio(neg);
}
void stampaCliente(Persona cliente){
    std::cout << cliente.nome << " ha " << cliente.oggetto.nome;
    std::cout << " e " << cliente.soldi << " Euro\n";
}

int main() {
    srand(time (0));
   // for(int t=0;t<5;t++){
    Negozio neg;
    string nome;
    inizializzaNegozio(neg,nome);
    stampaNegozio(neg);
   
    for(int k=0;k<c;k++){
         Persona cliente;
    cliente.nome=nomic[rand()%6];
    stampaCliente(cliente);
    preleva(neg,2,1);
    cliente.oggetto = neg.cose[rand()%3];
    cliente.soldi -= neg.cose[2].prezzo;
    stampaCliente(cliente);
    }
    stampaNegozio(neg);
    cout<<"\n\n\n\n\n";
//}
   return 0;
}

Sample Dart Online Program

/* Simple Hello, World! program */
void main(){
   print("Hello, World!");
}

Text Formatting using HTML5 and CSS

<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<style type="text/css">
div
{
   width:100px;
   height:75px;
   background-color:red;
   border:1px solid black;
}
#div2
{
   transform:rotate(30deg);
   -ms-transform:rotate(30deg); /* IE 9 */
   -moz-transform:rotate(30deg); /* Firefox */
   -webkit-transform:rotate(30deg); /* Safari and Chrome */
   -o-transform:rotate(30deg); /* Opera */
   background-color:yellow;
}
</style>
</head>
<body>
<div>Hello, World!</div>
<div id="div2">Hello, CSS3!</div>
</body>
</html>

JavaScript Html Sample Program

<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
function sayHello() {
   document.write("Hello, Coding Ground!");
}
sayHello();
</script>
</head>
<body>
</body>
</html>

Call By Address in C and C++

cpp

#include<iostream>
using namespace std;

void div(int a, int b, int *quotient, int *remainder){
   *quotient = a / b;
   *remainder = a % b;
}

main(){
   int a = 76, b = 10;
   int q, r;

   div(a, b, &q, &r);
   cout << "Quotient is: "<< q <<"\nRemainder is: "<< r <<"\n";
}

Evaluation function parameters in C++

cpp

#include<iostream>
using namespace std;

void test_function(int x, int y, int z){
   cout << "The value of x: " << x << endl;
   cout << "The value of y: " << y << endl;
   cout << "The value of z: " << z << endl;
}

main(){
   int a = 15;
   test_function(a++, a++, a++);
}

Java Program to get the difference between two time zones

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class Demo {
	public static void main(String[] args) {
		ZoneId zone1 = ZoneId.of("America/Panama");
		ZoneId zone2 = ZoneId.of("Asia/Taipei");
		LocalDateTime dateTime = LocalDateTime.of(2019, 04, 11, 10, 5);
		ZonedDateTime panamaDateTime = ZonedDateTime.of(dateTime, zone1);
		ZonedDateTime taipeiDateTime = panamaDateTime.withZoneSameInstant(zone2);
		System.out.println("Difference between two time zones in seconds = "+taipeiDateTime.getOffset().getTotalSeconds());
	}
}

Java Program to create custom DateTime formatter

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
public class Demo {
	public static void main(String[] args) {
		DateTimeFormatter dtFormat =  new DateTimeFormatterBuilder()
		.appendValue(ChronoField.HOUR_OF_DAY)
		.appendLiteral(":")
		.appendValue(ChronoField.MINUTE_OF_HOUR)
		.appendLiteral(":")
		.appendValue(ChronoField.SECOND_OF_MINUTE)
		.toFormatter();
		System.out.println("Time = "+dtFormat.format(LocalDateTime.now()));
		dtFormat =  new DateTimeFormatterBuilder()
		.appendValue(ChronoField.YEAR)
		.appendLiteral("/")
		.appendValue(ChronoField.MONTH_OF_YEAR)
		.appendLiteral("/")
		.appendValue(ChronoField.DAY_OF_MONTH)
		.toFormatter();
		System.out.println("Date = "+dtFormat.format(LocalDateTime.now()));
	}
}

Java Program to convert java.util.Date to java.time.LocalDateTime

import java.time.ZoneId;
import java.util.Date;
public class Demo {
	public static void main(String[] args) {
		java.util.Date  date = new Date();
		System.out.println("Date = "+date);
		java.time.LocalDateTime dateTime = java.time.LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
		System.out.println("LocalDateTime = "+dateTime);
	}
}

1 2 3 4 5 6 7 ... 8401 Next
Advertisements
Loading...

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