Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will store 7 integers (entered by the user) into an array c

ID: 3569295 • Letter: W

Question

Write a program that will store 7 integers (entered by the user) into an array ca lled "list1". Next, prompt the user for 5 integers and put them into an array called "list2". Now, list all of the numbers that are in BOTH lists. Below is a sample run. NOTE: Include a functio n called "getNumber" which asks the user for a number, then RE TURNS it to calling function (in this case, "main").

List 1

------

Enter an integer: 4

Enter an integer: 2

Enter an integer: 7

Enter an integer: 1

Enter an integer: 5

Enter an integer: 6

Enter an integer: 3

List 2

------

Enter an integer: 11

Enter an integer: 9

Enter an integer: 7

Enter an integer: 5

Enter an integer: 3

The numbers that are in both lists are:

3, 5, 7

NOTE: DO NOT USE GLOBAL VARIABLES!!!!! A global variable is a variable that is defined outside of any function (including ma in). We don't cover them in this co urse because they are generally a very bad idea. So, don't do this in your projects!

Explanation / Answer

#include<stdio.h>

#include<conio.h>

int getNumber()

{

int list1[7],list2[5],list3[5], i,j;

printf("List1");

printf("----------")

for(i=0;i<7;i++)

{

printf("enter an integer:");

scanf(%d,&list1[i]);

}

printf("List2");

printf("----------")

for(j=0;j<5;i++)

{

printf("enter an integer:");

scanf(%d,&list2[i]);

}

for(i=0;i<7;i++)

{

      for (j=0;j<5;j++)

         {

            if(list1[i]==list2[j])

             {

           list3[j]=list2[j];

             }

              return(list3[])

}

void main()

{

int list[5],i;

printf("The numbers that are in both lists are:");

for(i=0;i<5;i++)

{

printf(%d,list[i]);

}

getch();

}

            

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote