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