#include<stdio.h> int main() { int i = 1, j = 5; printf("----------\n"); printf("a \t b \n"); printf("----------\n"); /* logic: while loop repeats * 5 times i.e. until * the condition i<=5 fails */ while (i <= 5) { /* i and j value printed */ printf("%d \t %d\n", i, j); /* i and j value incremented by 1 for every iteration */ i++; j--; } printf("----------"); return 0; } OUTPUT:-- ------
a b
------
1 5
2 4
3 3
4 2
5 1
------
No comments:
Post a Comment