Computer Science, asked by bksbboy, 1 month ago

write a program in Cto print the numbers from 4to 9 and their squares?

Answers

Answered by anindyaadhikari13
5

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - C.

#include <stdio.h>

int main() {

   printf("Numbers from 4 to 9:\n");

   for(int i=4;i<=9;)

       printf("%d ",i++);

   printf("\nTheir Squares:\n");

   for(int i=4;i<=9;i++)

       printf("%d ",i*i);

   return 0;

}

\textsf{\large{\underline{Logic}:}}

  • Iterate loop in the range i = 4 to 9.
  • Display the value of 'i'.
  • Again, iterate loop in the same range.
  • Display the square of each number in the range.

See attachment for output.

Attachments:
Similar questions