Program
#include <stdio.h> int main() { printf("*********************************************************"); printf("\n*********************************************************"); printf("\n** WAP to print numbers 10 to 1 using loops **"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n*********************************************************"); printf("\n*********************************************************\n"); int i; printf("\nUsing For loop\n"); for (i = 10; i >= 1; i--) printf("%d\t", i); printf("\n\nUsing while loop\n"); i = 10; while (i >= 1) { printf("%d\t", i); i--; } printf("\n\nUsing do while loop\n"); i = 10; do { printf("%d\t", i); i--; } while (i >= 1); return 0; }
Output
*************************************************************************** *************************************************************************** ** WAP to print numbers 10 to 1 using loops ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** *************************************************************************** *************************************************************************** Using For loop 10 9 8 7 6 5 4 3 2 1 Using while loop 10 9 8 7 6 5 4 3 2 1 Using do while loop 10 9 8 7 6 5 4 3 2 1