Expand the code below to display both the value of the loop variable and this value squared. Put the pairs of values on a new line.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i;
int a;
int b;
do
{
printf("Please enter the lower value: ");
scanf("%d", &a);
printf("Please enter the upper value: ");
scanf("%d", &b);
if (a>b)
printf("The upper value must be greater than the lower
value\n\n");
}
while (a>b);
for(i=a; i<=b; i++)
printf("%d ", i);
return 0;
}
#include <stdio.h> #include <stdlib.h> int main(void) { int i; int a; int b; do { printf("Please enter the lower value: "); scanf("%d", &a); printf("Please enter the upper value: "); scanf("%d", &b); if (a > b) printf("The upper value must be greater than the lower value\n\n"); } while (a > b); for (i = a; i <= b; i++) printf("%d, %d\n", i, i*i); return 0; }
Get Answers For Free
Most questions answered within 1 hours.