C program to Print 1 to 10

Below is C program to Print 1 to 10 .

Program: Print 1 to 10 using while loop

/* Print 1 to 10 using while loop */
#include<stdio.h>
int main()
{
    int i=1;
    while(i <= 10)
    {
        printf("%d\n",i);
        i++;
    }

    return 0;
}

Program: Print 1 to 10 using for loop

/* Print 1 to 10 using for loop */
#include<stdio.h>
int main()
{
    int i;
    for(i=1;i<=10;i++)
        printf("%d\n",i);

    return 0;
}

No comments:

Post a Comment