Skip to content

Instantly share code, notes, and snippets.

@josuenoel
Last active August 29, 2015 14:26
Show Gist options
  • Save josuenoel/2990438d34d6fcca5fbb to your computer and use it in GitHub Desktop.
Save josuenoel/2990438d34d6fcca5fbb to your computer and use it in GitHub Desktop.
Primer Achivit
;Este programa calcula el area de un circulo a partir del radio ingresado
(defun AreaOfCircle()
(terpri)
(princ "Ingrese el radio: ")
(setq radius (read))
(setq area (* 3.1416 radius radius))
(princ "Area: ")
(write area))
(AreaOfCircle)
C AREA OF A TRIANGLE - HERON'S FORMULA
C INPUT - CARD READER UNIT 5, INTEGER INPUT
C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING
INTEGER A,B,C
READ(5,501) A,B,C
FORMAT(3I5)
IF(A.EQ.0 .OR. B.EQ.0 .OR. C.EQ.0) STOP 1
S = (A + B + C) / 2.0
AREA = SQRT( S * (S - A) * (S - B) * (S - C) )
WRITE(6,601) A,B,C,AREA
FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,12HSQUARE UNITS)
STOP
END
INPUT "What is your name: ", U$
PRINT "Hello "; U$
INPUT "How many stars do you want: ", N
S$ = ""
FOR I = 1 TO N
S$ = S$ + "*"
NEXT I
PRINT S$
INPUT "Do you want more stars? ", A$
IF LEN(A$) = 0 THEN GOTO 90
A$ = LEFT$(A$, 1)
IF A$ = "Y" OR A$ = "y" THEN GOTO 30
PRINT "Goodbye "; U$
END
choices [[small medium large]
[vanilla [ultra chocolate] lychee [rum raisin] ginger]
[cone cup]]
to choices :menu [:sofar []]
if emptyp :menu [print :sofar stop]
foreach first :menu [(choices butfirst :menu sentence :sofar ?)]
end
//Se pide al usuario un número y se imprime si este es par o impar
#include <stdio.h>
#include <stdlib.h>
int main(void){
int i;
printf("Introduzca número:");
scanf("%d",&i);
if (i%2==0) {
printf("Es par.");
} else {
printf("Es impar.");
}
system("PAUSE");
return 0;
}
//El usuario ingresa su nombre y el programa lo saluda :D
import java.util.Scanner;
public class LeerTeclado{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.print( "Ingresa tu nombre: " );
String nombre = s.nextLine();
System.out.println( "Hola " + nombre + "!" );
}
}
| ?- read(X).
|: 'hello ana'.
'hello ana'.
X = 'hello ana' ?
yes
/* El usuario ingresa 5 numeros y el programa devuelve su suma */
#include<stdio.h>
#include<conio.h>
main() {
int num1,num2,num3,num4,num5;
printf("\t*****SUMA*****\n");
printf("introduce numero 1: ");
scanf("%d",&num1);
printf("introduce numero 2: ");
scanf("%d",&num2);
printf("introduce numero 3: ");
scanf("%d",&num3);
printf("introduce numero 4: ");
scanf("%d",&num4);
printf("introduce numero 5: ");
scanf("%d",&num5);
printf("\nel resultado de la usma es:%d",num1+num2+num3+num4+num5);
getch;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment