While loop in C

Write a program to use while loop in C.

Example:
Input:  n = 5
Output: Numbers till 5 are:
0 1 2 3 4 5 

C Program

#include <stdio.h>

int main()

{
    int n = 5;
    printf("Numbers till %d are:\n"n);

    int i = 0;
    while (i <= n)
    {
        printf("%d "i);
        i++;
    }

    return 0;
}


No comments:

Post a Comment