using C programming You are given an array of integers \' array[]\' and an input
ID: 3794485 • Letter: U
Question
using C programming
Explanation / Answer
the following is the program to do the required
#include <stdio.h>
int main(void)
{
//variables to be used
int i, n,j,xsquare,square1,square2;
int array [10];
//input the value of x
printf("Enter the value of x: ");
scanf("%d", &n);
// x sqaure value is calculated here
xsquare = n*n;
printf("Enter the numbers for array (max 10 allowed): ");
for (i=0;i<10;i++) {
scanf("%d",&array[i]);
}
//for loop for matching pairs
for (i = 0; i <= 9; i++){
for (j = 0; j <= 9; j++){
square1 = i*i;
square2 = j*j;
//compare the array square plus the input one
if(xsquare == square1 + square2)
printf("The pair are %d and %d",j,i,xsquare);
}
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.