Program
#include <stdio.h> int main() { printf("****************************************************************"); printf("\n****************************************************************"); printf("\n** WAP to print numbers from a to b using for loop **"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n****************************************************************"); printf("\n****************************************************************\n"); int a, b, i; printf("enter a and b"); scanf("%d%d", &a, &b); if (a <= b) { printf("\n\nNumbers in increasing order are\n"); for (i = a; i <= b; i++) printf("%d\t", i); } else { printf("\n\nNumbers in decreasing order are\n"); for (i = a; i >= b; i--) printf("%d\t", i); } return 0; }
Output 1
**************************************************************** **************************************************************** ** WAP to print numbers from a to b using for loop ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** **************************************************************** **************************************************************** enter a and b 4 12 Numbers in increasing order are 4 5 6 7 8 9 10 11 12
**************************************************************** **************************************************************** ** WAP to print numbers from a to b using for loop ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** **************************************************************** **************************************************************** enter a and b 12 4 Numbers in decreasing order are 12 11 10 9 8 7 6 5 4