Skip to content

Instantly share code, notes, and snippets.

@adammw
Created March 16, 2011 10:58
Show Gist options
  • Save adammw/872317 to your computer and use it in GitHub Desktop.
Save adammw/872317 to your computer and use it in GitHub Desktop.
/* FILE: error1.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 10:57:24 EST 2011>
*/
#include <stdio.h>
int main()
{
printf("Hello there\n");
return 0; /* missing semicolon */
}
/* FILE: error10.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:38:18 EST 2011>
*/
#include <stdio.h> /* include typo */
int main()
{
printf("C# or be flat/n");
return 0;
}
/* FILE: error11.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:38:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints the difference of two numbers*/
printf("2 - 3 = %i\n", 2 - 3); /* used + instead of -*/
return 0;
}
/* FILE: error12.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:48:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints the percentage of two numbers*/
printf("120 / 100 = %.0f %%\n", (120.0 / 100.0)*100); /*used modulus instead of division*/
return 0;
}
/* FILE: error13.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:49:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program evaluates an equation*/
printf("2(1 + 3) = %i\n", 2 * (1 + 3)); /*brackets not specified*/
return 0;
}
/* FILE: error14.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:49:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program evaluates an equation*/
printf("(0.9 + 0.1) * 10 = %f\n", (0.9 + 0.1) * 10); /*brackets not specified*/
return 0;
}
/* FILE: error15.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:51:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints the slope of a line*/
printf("5.0-2.5 / 10.0-9.0 = %f\n", (5.0-2.5) / (10.0-9.0)); /*brackets not specified*/
return 0;
}
/* FILE: error16.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:53:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints the sum of two numbers*/
printf("The sum of %i + %i = %i\n", 2, 3, 2+3); /*forgot to specify result*/
return 0;
}
/* FILE: error17.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:56:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program evaluates an equation*/
printf("10 / (2 - 4/2) = %f\n", 10 / (2 - (4/2.0)));
/* error in equation - division by zero */
return 0;
}
/* FILE: error18.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:58:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program evaluates an equation*/
printf("10 / (2 - 4/2) = %i\n", 10 / (2 - 4.0/2));
return 0;
}
/* FILE: error19.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:59:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program evaluates an equation*/
printf("10 / (2 - 4/2) = %i\n", 10 / (2 - 4/2));
return 0;
}
/* FILE: error2.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:04:55 EST 2011>
*/
#include <stdio.h>
int main()
{
printf("I am a teapot\n"); /* missing closing quote */
return 0;
}
/* FILE: error20.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 11:59:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints a number*/
printf("%f\n", 10.23587); /* should be %f not %i as value is a float */
return 0;
}
/* FILE: error21.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Thu Mar 10 12:00:18 EST 2011>
*/
#include <stdio.h>
int main()
{
/*This program prints a number*/
printf("%i\n", 10); /* type specifier wrong - %f instead of %i */
return 0;
}
/* FILE: error3.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:07:07 EST 2011>
*/
#include <stdio.h> /* semicolon here not required */
int main()
{
printf("Real Programmers drink Java\n");
return 0;
}
/* FILE: error4.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:08:45 EST 2011>
*/
#include <stdio.h>
int main()
{
printf("The Leith Police Never Sleeps\n"); /* print() instead of printf() */
return 0;
}
/* FILE: error5.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:10:46 EST 2011>
*/
#include <stdio.h>
int main()
{
printf("VB sucks\n");
return 0;
}
/* return not inside function */
/* FILE: error6.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:13:18 EST 2011>
*/
#include <stdio.h>
int main() /* main spelt wrong */
{
printf("C# or be flat\n");
return 0;
}
/* FILE: error7.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:14:59 EST 2011>
*/
#include <stdio.h>
int main()
{
printf("C# or be thin\n");
return 0; /* keyword spelt wrong */
}
/* FILE: error8.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:18:18 EST 2011>
*/
#include <stdio.h>
int main() /* type declared as void instead of int */
{
printf("C# or be flat\n");
return 0;
}
/* FILE: error9.c
* Week 2 lab exercise 1
* Author: Adam Malcontenti-Wilson <[email protected]>
* Last Modified <Wed Mar 9 11:18:18 EST 2011>
*/
#include <stdio.h>
int main() /* declarition type invalid */
{
printf("Cb or B#\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment