c programming language #2
TRANSCRIPT
What is Data?
2.3
/* ch2 int_dec.c */
#include <stdio.h>#include <stdlib.h> int main(){
int number;
number = 10;printf("Number = %d Double = %d.\n", number, number*2);system("PAUSE");return 0;
}
2.3.1
/* ch2 oct_hex.c */
#include <stdio.h>#include <stdlib.h> int main(){
int base;base = 109;
printf("Dec = %d Oct = %o Hex = %x.\n", base, base, base);printf("Dec = %#d Oct = %#o Hex = %#x.\n", base, base, base);printf("Dec = %#d Oct = %#o Hex = %#X.\n", base, base, base);system("PAUSE");return 0;
}
2.3.2
/* ch2 ints.c */
#include <stdio.h>#include <stdlib.h> int main(){
short sint = 32767;int i = 32768;long int lint = 2147483647;
printf(" %hd %d\n", sint, sint);printf(" %hd %d\n", i, i);printf(" %ld %d\n", lint, lint);system("PAUSE");return 0;
}
2.5
/* ch2 floats.c */
#include <stdio.h>#include <stdlib.h> int main(){
float pi = 34.898;double electron = 1.6E-19;
printf("PI = %f or %E.\n", pi, pi);printf("Electron = %f or %e.\n", electron, electron);system("PAUSE");return 0;
}
#include <stdio.h>
int main( )
{
int value;
value = 6 + 4 * 10;
printf(“%d\n”, value);
getch();
return 0;
}
math.c
a = b + c;
a = 10
b = 3
c = 2
a = ?
b = ?
c = ?
#include <stdio.h>
#include <stdlib.h>
int main( )
{
printf("hello, world\r”);
printf(“Hi world”);
printf(“\b\b\b\b\b everyone \n”);
system(“PAUSE”);
return 0;
}
2.9.1.c
#include <stdio.h>
#include <stdlib.h>
int main( )
{
printf(“ /\\\n”);
printf(“ / \\\n”);
printf(“ / \\\n”);
printf(“ / \\\n”);
printf(“+----------------+\n”);
system(“PAUSE”);
return 0;
}
2.9.2.c
HomeWork #4
2.10 No.1 (P.26)
Write or Print in A4 Paper
Name & I.D.