• Non ci sono risultati.

Lezione 7 – Programmare in Linux

N/A
N/A
Protected

Academic year: 2021

Condividi "Lezione 7 – Programmare in Linux"

Copied!
2
0
0

Testo completo

(1)

AA. 2016/2017 – Angelo Genovese – Introduzione a Linux

Lezione 7 – Programmare in Linux

Lezione 7 – Programmare in Linux

ESERCIZI

• Q: Create uno script bash che stampa a video «hello world»

o È necessario anche impostare i privilegi di esecuzione o A: nano hello_world

---

#!/bin/sh

echo “hello world”

--- Ctrl + O, Ctrl + X

sudo chmod +x hello_world ./hello_world

• Q: Create uno script che somma due numeri inseriti dall’utente o È possibile usare un ciclo per ripetere l’operazione o A: nano sum

---

#!/bin/bash

echo inserisci un numero read a

echo un altro read b

echo la somma è: $(($a+$b)) ---

Ctrl + O, Ctrl + X sudo chmod +x sum ./sum

(2)

AA. 2016/2017 – Angelo Genovese – Introduzione a Linux

Lezione 7 – Programmare in Linux

• Q: Create un programma C che stampa a video «hello world» ed eseguitelo tramite terminale o A: nano hello_world.c

---

#include <stdio.h>

int main() {

printf("Hello, world!\n");

return 0;

}

--- gcc –c hello_world.c

gcc hello_world.o –o hello_world.bin ./hello_world.bin

• Q: Utilizzate un IDE per compilare il programma o A: (esempio) sudo apt-get install eclipse

• Q: (Per chi conosce Java) ripetete le operazioni utilizzando il linguaggio Java

Riferimenti

Documenti correlati

Since contact points between two touching planes should share the same grey value (i.e. same height), considering the main plane and its touching ones (slaves) it is possible to

During a three-month rearing period we compared the (1) survival rate, (2) growth at moult, (3) number of moults, and (4) overall growth of the young of the year (YOY) of two

HAQ-DI: Health Assessment Questionnaire Disability Index; HRQoL: health- related quality of life; KING: Kick-off of the Italian Network for Gout; MCS: Mental Component Summary;

Magnetic dipole moment μ as a function of the maximum field strength inside the star B max for an equilibrium sequence with the purely poloidal magnetic field and fixed baryon mass M

We demonstrate how our local pyramidal descriptors improve image classification results for the standard BOW approach, as well as for three successful and more recent

The MBR, working at a mean sludge retention time of 144 days and with mixed liquor suspended solids of 17 g/L, achieved high removal rates of conventional contaminants, with more