144 Programming and Data Structures
OUTPUT :
Enter a Number : 100
Number : 1 & it's Cube : 1
Number : 2 & it's Cube : 8
Number : 3 & it's Cube : 27
Number : 4 & it's Cube : 64
Explanation Here in the above program the programmer has to enter the number up to which the
perfect cubes are to be obtained. For example if the user enters 100 the perfect cubes up to 100 are
1,8,27 & 64. Here the two f o r loops are used. The outer f o r loop varies up to the entered number.
The inner f o r loop varies up to value of ' i '. For each value of 1 j ' its cube is calculated and
checked with the value of % i '. If the I f condition is true the perfect cubes is printed otherwise the
loop continues. Thus, all the perfect cubes up to a given number are displayed.
6.30 Write a program to display numbers 1 to 100 using A SC II values from 48 to 57. Use
nested loops.
# include <stdio.h>
main()
{
in t i f j= 0 ,k = -9 ;
c l r s c r ();
printf ("t Table o f l to 100 Numbers Using ASCII Values n");
printf ("f==== == = == === ======= ===== ===== ======«");
for (i=48;i<=57;i++,k++)
fo r (j=49;j<=57;j++)
printf ("%5c%c",i,j);
if (k!=l)
printf (“ %c%c",i+l,48);
if (k==0) printf (“b%d%d%d",k+l,k,k);
printf (“
");
I
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