











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












*/ This program prints a list of
{ int main (void)#include <stdio.h>
int i; for (i = 0; i < 10; i = i + 1)
printf (“i is %d\n”, i);
return 0;
}
Here’s example C program
it’s not much sophisticated
it also doesn’t do much of any practical use
How we manipulate data in our program
Name associated with some memory
Has a specific data type
In this program:
a variable named
(^) i (^) is used to hold an integer value
(^) i’ s value goes from 0 to 9
{ int main (void) #include <stdio.h>
int i; for (i = 0; i < 10; i
i
+ 1)
printf (“i is %d\n”,
i);
return 0;
/ This program prints a list*
of
*** integers, from 0 to 9./*
#include <stdio.h> int main (void)
int i; for (i = 0; i < 10; i
i
+ 1)
printf (“i is %d\n”,
i);
return 0;
Here’s that include directive again.
like before, this allows printf to work
we’ll just do it now, without worrying about why
/ This program prints a list*
of
*** integers, from 0 to 9./*
{ int main (void)#include <stdio.h>
for (i = 0; i < 10; i = i + 1)int i;
printf (“i is %d\n”,
i);
return 0;
(^) main
(^) function.
*/ This program prints a list of
*/
{ int main (void)#include <stdio.h>
int i; for (i = 0; i < 10; i = i + 1)
printf (“i is %d\n”, i);
return 0;
}
it’s called a declaration
it tells the compiler that we’ll be using a variable
named i
it holds an integer
/ This program prints a list*
of
*** integers, from 0 to 9.**
#include <stdio.h> int main (void)
for (i = 0; i < 10; i = i + 1)int i;
printf (“i is %d\n”,
i);
return 0;
it will execute its contents 10 times
each time, i will have a different value
from 0
*/ This program prints a list of
from
*0 to 9. /
#include <stdio.h> int main (void)
{
int
i;
printf (“i is 9\n”);printf (“i is 8\n”);printf (“i is 7\n”);printf (“i is 6\n”);printf (“i is 5\n”);printf (“i is 4\n”);printf (“i is 3\n”);printf (“i is 2\n”);printf (“i is 1\n”);printf (“i is 0\n”);
return
0;
}