A program to print the numbers from 1 to 10 and their squares.

#include 

int main()
{
int i;

for(i = 1; i <= 10; i = i + 1)
printf("%d %d\n", i, i * i);

return 0;
}

Exercise 4. Write a program to print a simple triangle of asterisks.

#include "stdio.h"

int main()
{
int i, j;

for(i = 1; i <= 10; i = i + 1)
{
for(j = 1; j <= i; j = j + 1)
printf("*");
printf("\n");
}

return 0;
}

No comments:

Post a Comment