|
#include <stdio.h>
int main()
{
printf( "Welcome\nto\nC!\n" );
return 0;
}
|
#include <stdio.h>
int main()
{
int integer1, integer2, sum; /* declaration */
printf( "Enter first integer\n" ); /* prompt */
scanf( "%d", &integer1 ); /* read an integer */
printf( "Enter second integer\n" ); /* prompt */
scanf( "%d", &integer2 ); /* read an integer */
sum = integer1 + integer2; /* assignment of sum */
printf( "Sum is %d\n", sum ); /* print sum */
return 0; /* indicate that program ended successfully */
} |
|
#include <stdio.h>
main()
{
int num1, num2;
printf( "Enter two integers, and I will tell you\n" );
printf( "the relationships they satisfy: " );
scanf( "%d%d", &num1, &num2 ); /* read two integers */
if ( num1 == num2 )
printf( "%d is equal to %d\n", num1, num2 );
if ( num1 != num2 )
printf( " %d is not equal to %d\n ", num1, num2 );
if ( num1 < num2 )
printf( "%d is less than %d\n", num1, num2 );
if ( num1 > num2 )
printf( "%d is greater than %d\n", num1, num2 );
if ( num1 <= num2 )
printf( "%d is less than or equal to %d\n",
num1, num2 );
if ( num1 >= num2 )
printf( "%d is greater than or equal to %d\n",
num1, num2 );
return 0; /* indicate program ended successfully */
} |
|
#include <stdio.h>
int main()
{
int count = 1;
while ( count <= 10 ) {
printf( "%s\n", count % 2 ? "****" : "++++++++" );
++count;
}
return 0;
} |
#include <stdio.h>
int main()
{
int row = 10, column;
while ( row >= 1 )
{
column = 1;
while ( column <= 10 ) {
printf( "%s", row % 2 ? "<": ">" );
++column;
}
--row;
printf( "\n" );
}
return 0;
} |