58127-1 C-ohjelmointi - Syksy 2000 : Kertausta: Luento1
#include<stdio.h> int main(void) { int a = -100000; unsigned int b = 199999; short c = -123; unsigned short d = 123; float f = 123.456; double e = 3.1234567890; long g = -(2 << 20); unsigned long h = 2 << 20; long double i = 3.1234567890875; char s[] = "Kaikki hyvin"; /* Kokeillaanpa tulostaa */ printf("int %d\n",a); printf("unsigned int %u\n",b); printf("unsigned int virhe %u\n",a); printf("short %hd\n",c); printf("unsigned short %hu\n",d); printf("unsigned short virhe %hu\n",c); printf("float %f\n",f); printf("double %g\n",e); printf("long %ld\n",g); printf("long %d\n",g); printf("unsigned long %lu\n",h); printf("unsigned long virhe %lu\n",g); printf("long double %Lg\n",i); printf("merkkijono %s\n",s); /* Luetaan joitakin muuttujia sisään */ scanf("%d",&a); scanf("%u",&b); scanf("%f",&f); scanf("%g",&e); scanf("%ld",&g); scanf("%s",s); }
Jan Lindström (Jan.Lindstrom@cs.Helsinki.FI)