Pages

Sample C Programs

First Simple C program:

#include

main()
{
puts ("Hello World!");
}

------------------------------

C program using if clause:

#include

main()
{
int i=1; /* Defining an integer variable.*/

/*
i == 1 expression is evaluated. If TRUE the
first block is executed.
if i == 1 is FALSE then else block will be executed
*/

if (i == 1)
{
puts ("i is equal to 1\n");
}
else
{
puts("i is NOT equal to 1");
}
}
----------------------------

A Sample program using a while loop:

#include

main()
{
int i=1; /* Defining an integer variable. */

/*
i <= 10 expression is evaluated. If TRUE the
block is executed.
*/

while (i <= 10)
{
printf ("i is %i\n", i);
i++;
}
}

Error and Fix Travel

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.

No comments:

Post a Comment