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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


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

Add a comment
Know the answer?
Add Answer to:
Write a Program in C language for: 1. Create a C program to read 7 integers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

  • Write a C++ program that simulates a lottery game. Your program should use functions and arrays....

    Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...

  • Using Atmel studio 7 -C language programming Write a program to find the median of an...

    Using Atmel studio 7 -C language programming Write a program to find the median of an array of 8-bit unsigned integers. When the array has an even number of elements, the median is defined as the average of the middle two elements. Otherwise, it is defined as the middle element of the array. You need to sort the array in order to find the median. SHOW THAT THE CODE IS WORKING PROPERLY IN ATMEL STUDIO 7

  • 2. Write a C++ program, that generates a set of random integers and places them in...

    2. Write a C++ program, that generates a set of random integers and places them in an array. The number of values generated and their range are entered by the user. The program then continually prompts the user for one of the following character commands: a: display all the values I: display the values less than a given value g display the values greater than a given value e: display all odd values o: display all even values q: quit...

  • Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and...

    Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and stores them in an array, and then calls the following two functions and prints the results in a readable format. The two functions are: smallestLargest: computes the smallest and the largest values in the array. oddEven: computes the number of even integers and the number of odd integers.

  • C# prograaming language 1. write a program that generates 10,000 random integers in the range of ...

    c# prograaming language 1. write a program that generates 10,000 random integers in the range of 0-9 and them in binary search tree. 2. use any sort algorithm (insertion, bubble, quick...) to display a list of each of the integers and how many times they appear. 3. at last, add ruction to the BinarySearchTree class that count the number of edges in a tree. Write a program that generates 10,000 random integers in the range of 0-9 and store them...

  • (C++) Write a function, remove, that takes three parameters: an array of integers, the number of...

    (C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...

  • Can you please answer this in complete C++ program. I. Write a program that reads in...

    Can you please answer this in complete C++ program. I. Write a program that reads in an array of five integers al 5] and arses the mray in t fncion largest that rcurns the value of the largest element in the arrav, 2.Write a program that reads in two arrays, a[3] and b[3], and passes them to a function Scalarproduct that returns the scalar product of these arrays; the scalar product of two arrays is

  • Task 1 : Write a Java program that prompts for and reads 10 integers from the...

    Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT