Commit 2348a20c authored by L. Felipe Perrone's avatar L. Felipe Perrone
Browse files

Merge branch 'master' of gitlab.bucknell.edu:courses/csci206_lecture_examples

parents 08a902ac 29849450
/* nogood.c -- a program with errors
* Stephen Prata - C Primer Plus - Listing 2.4
*/
#include <stdio.h>
int main(void)
(
int n, int n2, int n3;
/* this program has several errors
n = 5;
n2 = n * n;
n3 = n2 * n2;
printf("n = %d, n squared = %d, n cubed = %d\n", n, n2, n3)
return 0;
)
int main(void)
{
double y[10];
double x;
y[0] = 3.1415926;
y[1] = 2.71828;
y[2] = 0;
y[10] = 666;
}
......@@ -9,6 +9,6 @@ int main(int argc, char* argv[]) {
printf("pi= %f\n\n", pi);
for (i=0; i<4; i++) {
printf("pf[%d]= %x\n", i, pf[i]);
printf("pf[%d]= %02hhx\n", i, pf[i]);
}
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
printf("hello C world\n");
int main(int argc, char* argv[])
{
printf("hello C world\n"); // from stdio.h
return EXIT_SUCCESS; // from stdlib.h
}
#include <stdio.h>
int main(void){
int i;
float x;
char text[80];
scanf("%d", &i);
scanf("%f", &x);
scanf("%s", text);
printf(" i= %d\n", i);
printf(" x= %f\n", x);
printf(" text= %s\n", text);
}
switch (i) {
case 1:
j = -i;
break;
case 2:
j += 123;
break;
case 3:
j = 999;
break;
default: {
j = 666;
}
break;
}
......@@ -5,8 +5,8 @@ int main(int argc, char* argv[]) {
int i = 7;
int j = -1;
int* pi = &i;
int* pj = &j;
int *pi = &i;
int *pj = &j;
printf(" i = %d\n", i);
printf(" j = %d\n", j);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment