There are three basic types of structures in C:
Sequential structures are simply a list of expressions that will be evaluated in order, for example:
Doing the same thing but with a switch:
If i is 2 then the program should print ``two''. However if the switch statement was:
don't forget the break statements
C does not have a true boolean variable. In C any nonzero integer is considered true and a 0 is considered false. For example
x = 10;
y = 20;
i = x < y;
if (i) {
/* this code should execute since i is non zero */
}
i = x > y;
if (i) {
/* this code should not execute since i is zero */
}
void main()
{
float i;
for (i = 0; i != 12; i++);
{
if (i % 3 = 0)
{
printf "%f" i;
}
}
}
int main()
{
int num;
printf("Please enter in a number: ");
scanf("%d", num);
if (num != 2 || num != 3)
{
printf("Your number does not equal 2 or 3\n");
}
return 0;
}
This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.50)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -no_subdir -split 0 -show_section_numbers /tmp/lyx_tmpdir2377Terqoc/lyx_tmpbuf237764EgkT/dis1.tex
The translation was initiated by Kevin Atkinson on 2002-02-14