Programming Examples
Write a program to display numbers 1 to 100 using ASCII values from 48 to 57
Write a program to display numbers 1 to 100 using ASCII values from 48 to 57. Use the nested loops.
Solution
#include<stdio.h>
# include<math.h>
void main()
{
int i,j=0,k= -9;
clrscr();
printf(“\t Table of 1 to 100 Numbers Using ASCII Values \n”);
printf(“\t ===== == = == === ======= ===== ===== ======\n”);
for(i=48;i<=57;i++,k++)
{
for(j=49;j<=57;j++)
printf(“%5c%c”,i,j);
if(k!=1)
printf(“%5c%c”,i+1,48);
if(k==0)
printf(“\b\b%d%d%d”,k+1,k,k);
printf(“\n\n”);
}
getch();
}
Output
OUTPUT:
Table of 1 to 100 Numbers Using ASCII Values
==== == = == === ======= ===== ===== ==
01Â 02Â 03Â 04Â 05Â 06Â 07Â 08Â 09Â 10
11Â 12Â 13 14Â 15Â 16Â Â 17Â 18Â 19Â 20
21Â 22Â 23Â 24Â 25Â 26Â 27Â 28Â 29Â 30
31Â 32Â 33Â 34Â 35Â 36Â 37Â 38Â 39Â 40
41Â 42Â 43Â 44Â 45Â 46Â 47Â 48Â 49Â 50
51Â 52Â 53Â 54Â 55Â 56Â 57Â 58Â 59Â 60
61Â 62Â 63Â 64Â 65Â 66Â 67Â 68Â 69Â 70
71Â 72Â 73Â 74Â 75Â 76Â 77Â 78Â 79Â 80
81Â 82Â 83Â 84Â 85Â 86Â 87Â 88Â 89Â 90
91Â 92Â 93Â 94Â 95Â 96Â 97Â 98Â 99Â 100