gcc - GNU project C and C++ compiler
# hostname
MySolaris
# gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
Configured with: /builds2/sfwnv-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++,f77,objc --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-20050802)
# cat hw.c
#include
main()
{
printf("hello, world\n");
}
# gcc hw.c
# ls -l a.out
-rwxr-xr-x 1 root root 8196 2011-10-04 18:26 a.out
# file a.out
a.out: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped, no debugging information available
# ./a.out
hello, world
# cp hw.c forstatement.c
# cat forea[K[Kstatement.c
#include
main()
{
int i;
for (i=1; i<10; i++)
{
printf("Summation of %d+%d=%d\n", i, i, i+i);
printf("Subtraction of %d-%d=%d\n", i, i, i-i);
printf("Multiplication of of %d*%d=%d\n", i, i, i*i);
printf("Division of of %d/%d=%d\n", i, i, i/i);
}
return(0);
}
# gcc forstatement.c
# ls -l a.out
-rwxr-xr-x 1 root root 8436 2011-10-04 18:33 a.out
# file a.out
a.out: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped, no debugging information available
# ./a.out
Summation of 1+1=2
Subtraction of 1-1=0
Multiplication of of 1*1=1
Division of of 1/1=1
Summation of 2+2=4
Subtraction of 2-2=0
Multiplication of of 2*2=4
Division of of 2/2=1
Summation of 3+3=6
Subtraction of 3-3=0
Multiplication of of 3*3=9
Division of of 3/3=1
Summation of 4+4=8
Subtraction of 4-4=0
Multiplication of of 4*4=16
Division of of 4/4=1
Summation of 5+5=10
Subtraction of 5-5=0
Multiplication of of 5*5=25
Division of of 5/5=1
Summation of 6+6=12
Subtraction of 6-6=0
Multiplication of of 6*6=36
Division of of 6/6=1
Summation of 7+7=14
Subtraction of 7-7=0
Multiplication of of 7*7=49
Division of of 7/7=1
Summation of 8+8=16
Subtraction of 8-8=0
Multiplication of of 8*8=64
Division of of 8/8=1
Summation of 9+9=18
Subtraction of 9-9=0
Multiplication of of 9*9=81
Division of of 9/9=1
# cat nestedfor.c
#include
main()
{
int i;
int j;
for (i=1; i<5; i++)
{
for (j=11; i<15; i++)
{
printf("Summation of %d+%d=%d\n", i, j, i+j);
printf("Subtraction of %d-%d=%d\n", i, j, i-j);
printf("Multiplication of of %d*%d=%d\n", i, j, i*j);
printf("Division of of %d/%d=%d\n", j, i, j/i);
}
}
return(0);
}
# gcc nestedfor.c
# file a.out
a.out: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped, no debugging information available
# ./a.out
Summation of 1+11=12
Subtraction of 1-11=-10
Multiplication of of 1*11=11
Division of of 11/1=11
Summation of 2+11=13
Subtraction of 2-11=-9
Multiplication of of 2*11=22
Division of of 11/2=5
Summation of 3+11=14
Subtraction of 3-11=-8
Multiplication of of 3*11=33
Division of of 11/3=3
Summation of 4+11=15
Subtraction of 4-11=-7
Multiplication of of 4*11=44
Division of of 11/4=2
Summation of 5+11=16
Subtraction of 5-11=-6
Multiplication of of 5*11=55
Division of of 11/5=2
Summation of 6+11=17
Subtraction of 6-11=-5
Multiplication of of 6*11=66
Division of of 11/6=1
Summation of 7+11=18
Subtraction of 7-11=-4
Multiplication of of 7*11=77
Division of of 11/7=1
Summation of 8+11=19
Subtraction of 8-11=-3
Multiplication of of 8*11=88
Division of of 11/8=1
Summation of 9+11=20
Subtraction of 9-11=-2
Multiplication of of 9*11=99
Division of of 11/9=1
Summation of 10+11=21
Subtraction of 10-11=-1
Multiplication of of 10*11=110
Division of of 11/10=1
Summation of 11+11=22
Subtraction of 11-11=0
Multiplication of of 11*11=121
Division of of 11/11=1
Summation of 12+11=23
Subtraction of 12-11=1
Multiplication of of 12*11=132
Division of of 11/12=0
Summation of 13+11=24
Subtraction of 13-11=2
Multiplication of of 13*11=143
Division of of 11/13=0
Summation of 14+11=25
Subtraction of 14-11=3
Multiplication of of 14*11=154
Division of of 11/14=0
Please click on " man gcc " to see the Manual Page for this command.