Docsity

Lab Assignment 1 - Introduction to System Software | CS 0449, Lab Reports of Computer Science

Toggle sidebar
bg1
CS449 - Introduction to Systems Software
Fall 2007
LAB Assignment I
- For each of the problems below create a file containing the complete program.
- The filename must end with .c
- There are many C compilers; we are going to use the gcc compiler. This is the
GNU popular compiler plus it is available for many platforms.
- To compile a C program: gcc –o program program.c
- To run the program: ./program
Exercise I:
Write a program that outputs the following line:
The "first" \LAB\ in 'CS499'
Exercise II:
The following program has several errors. Modify it so that it will compile and run
without errors:
#include <stdio.h>
double f2c( double );
int main()
{
double fahrenheit = 32.4;
double celsius = f2c( fahrenheit );
printf( "fahrenheit = %d\t celsius =%f\n", fahrenheit, celsius);
return 0;
}
double f2c( float f ){
Return (f -32) *5 / 9;
}
pf2

Partial preview of the text

Download Lab Assignment 1 - Introduction to System Software | CS 0449 and more Lab Reports Computer Science in PDF only on Docsity!

CS449 - Introduction to Systems Software

Fall 2007

LAB Assignment I

  • For each of the problems below create a file containing the complete program.
  • The filename must end with .c
  • There are many C compilers; we are going to use the gcc compiler. This is the GNU popular compiler plus it is available for many platforms.
  • To compile a C program: gcc –o program program.c
  • To run the program: ./program

Exercise I:

Write a program that outputs the following line: The "first" \LAB\ in 'CS499'

Exercise II:

The following program has several errors. Modify it so that it will compile and run without errors: #include <stdio.h> double f2c( double ); int main() { double fahrenheit = 32.4; double celsius = f2c( fahrenheit ); printf( "fahrenheit = %d\t celsius =%f\n", fahrenheit, celsius); return 0; } double f2c( float f ){ Return (f -32) *5 / 9; }

Exercise III:

Using only the techniques you have learned up now, write a program that calculates the squares and cubes of the integers from 0 to 9 and print the following neatly and formatted table of values: 0 0 0 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 6 36 216 7 49 343 8 64 512 9 81 729

Exercise IV:

What happens when you try to compile and run the following program? #include <stdio.h> int main() { int k = 1; int i = ++k + + k++; printf( "%d\t%d\n", i, k ); return 0; } Try to explain the output

Exercise V:

What happens when you try to compile and run the following program? #include <stdio.h> int main() { double i = - -1-3 * 10/5 -1; printf( "%f\n", i ); return 0; } Try to explain the output