1 answer

Write a Program in C language for: 1. Create a C program to read 7 integers...

Question:

Write a Program in C language for:1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry of the array. Make your program work for odd number of elements and for even number of elements in the array 2. Write C program that reads 30 integers and stores them in two arrays of 15 elements each. The program is to check if the two arrays have common elements, and if yes, the program is to display the value of each common element and its position in both arrays. Otherwise, the C program is to display a message that their elements are different.

1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry of the array. Make your program work for odd number of elements and for even number of elements in the array 2. Write C program that reads 30 integers and stores them in two arrays of 15 elements each. The program is to check if the two arrays have common elements, and if yes, the program is to display the value of each common element and its position in both arrays. Otherwise, the C program is to display a message that their elements are different.

Answers


As per Chegg policy we are supposed to answer only first question. Request you to post other question separately.
#include <stdio.h>
int main(){
int num[30]; //maximum 30 numbers can be stored
int i, j;
int count;
int symmetric = 1; //assume to be symmetric
printf("How many numbers to be in array? ");
scanf("%d", &count);
printf("Enter the numbers: ");
for(i = 0; i < count; i++)
scanf("%d", &num[i]);
i = 0;
j = count - 1; //last array element
while(i < j){
if(num[i] != num[j])
{
symmetric = 0;
break;
}
i++;
j--;
}
if(symmetric)
printf("The array is symmetric\n");
else
printf("The array is not symmetric\n");
}
output
------
How many numbers to be in array? 7
Enter the numbers: 1 2 3 4 3 2 1
The array is symmetric

How many numbers to be in array? 6
Enter the numbers: 1 2 3 3 2 1
The array is symmetric
How many numbers to be in array? 7
Enter the numbers: 1 2 3 4 5 6 7
The array is not symmetric

.

Similar Solved Questions

1 answer
17. What's the maximum number of No. 10 wires that can enter a 4 x 1...
17. What's the maximum number of No. 10 wires that can enter a 4 x 1 1/2 octagon outlet box? A. Five O B. Four O C. Two O D. Six...
1 answer
Clear answer please 2: What is a plastic hinge in a steel beam? b) How many...
Clear answer please 2: What is a plastic hinge in a steel beam? b) How many plastic hinges need to form to cause collapse in a steel beam? 4. a)...
1 answer
Help!!! Question 2 --/3 View Policies Current Attempt in Progress At the beginning of the current...
help!!! Question 2 --/3 View Policies Current Attempt in Progress At the beginning of the current season on April 1, the ledger of Blossom Pro Shop showed Cash $3,110; Inventory $4,110; and Common Stock $7.220. The following transactions occurred during April 2022. bs, and balls on acc...
1 answer
Stellan Manufacturing is considering the following two investment​ proposals: Proposal X Proposal Y Investment $ 724...
Stellan Manufacturing is considering the following two investment​ proposals: Proposal X Proposal Y Investment $ 724 comma 000$724,000 $ 510 comma 000$510,000 Useful life 5 years 4 years Estimated annual net cash inflows received at the end of each year $ 158 comma...
1 answer
Background Information: Mary is a 12 month old who has been vomiting for the past 12...
Background Information: Mary is a 12 month old who has been vomiting for the past 12 hours. Mary woke up at 5 AM but has not been able to “hold anything down”. Mary’s mother is concerned because it is now 4:00 pm. Mary’s mother calls the primary care office and is recommended...
1 answer
If you wish to estimate a population mean with a margin of error ME=0.24 using a​...
If you wish to estimate a population mean with a margin of error ME=0.24 using a​ 95% confidence interval and you know from prior sampling that sigma squaredσ2 is approximately equal to 4.8, how many observations would have to be included in your​ sample? The number of observations...
1 answer
What is the domain of #f(x)=tan xcot x#?
What is the domain of #f(x)=tan xcot x#?...
1 answer
This is a very simplistic approach to protein folding which ignores solvent and volume affect but...
this is a very simplistic approach to protein folding which ignores solvent and volume affect but it allows us to practice what we have learned about thermodynamics and kinetics. enzymes are long chains of amino acids that have to fold in the proper way so as to exhibit enzyme activity. They can get...
1 answer
You are on the side of a road performing CPR on an adult who was involved...
You are on the side of a road performing CPR on an adult who was involved in a car accident. You suddenly notice that there is gasoline accumulating on the road near you and the person and that the car has started to smoke. If you stop CPR to move the person, the person might die. If you do not move...
1 answer
I need to analyze South Korea workforce (women's participation), economic (growth) performance with datas. And present...
I need to analyze South Korea workforce (women's participation), economic (growth) performance with datas. And present quantitative data and make comments. I will only get a full grade if I can comment on the future of this country as well as the present...
1 answer
Short Answer 1. A medical trial looking at the effectiveness of a new medication was carried...
Short Answer 1. A medical trial looking at the effectiveness of a new medication was carried on a sample of adults. 200 females and 100 males took part in the trial. Out of those people, 60 females and 50 males responded positively to the medication. Create a contingency table of the results and ans...
1 answer
Comfort Mattresses, Inc. sold 26,000 shares of its $1 par value common stock at a cash...
Comfort Mattresses, Inc. sold 26,000 shares of its $1 par value common stock at a cash price of $12 per share. The entry to record this transaction would be: Debit Common Stock $26,000; credit Cash $26,000. Debit Common Stock $26,000; debit Paid-in Capital in Excess of Par Value, Common Stock $286,...
1 answer
Patient is 65 years old 5. On the basis of Mr. Jones' age, which of the...
patient is 65 years old 5. On the basis of Mr. Jones' age, which of the following assessment findings will the nurse expect as a result of normal changes in the respiratory system related to age? A. Clubbing of Mr. Jones' fingernails B. Wheezes upon auscultation C. Retractions on inspiration...