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

You have an array called MyAarray) composed of numbers. You are to write a C+ wi

ID: 671494 • Letter: Y

Question

You have an array called MyAarray) composed of numbers. You are to write a C+ will check the number in the array to do the following: program that if the number is divisible by 3 you will insert it in asingle linkeg list called SingleListDiv3" if the number is divisible by 5, you will insert the number is a double linkedlist called if the number is divisible by 5. you will insert the number is a louble linkedjlist called e DoubleL istDiv5" otherwise, you will insert the number in an array called "LeftOverArray In your program you will have to make sure that the single linked list "SingleListDiv3" and the double linked list "Doublel istDivs are initialized to empty lists, Also the array LeftOverArray" is also initialized to an empty array You will write all the proper data structures needed and all then

Explanation / Answer

#include<iostream.h>


struct node
{
int data;
struct node *next;
}*head;

void add( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
if (head== NULL)
{
head=temp;
head->next=NULL;
}
else
{
temp->next=head;
head=temp;
}
}

void main()
{
   int cc=0,i,num MyArray[] = {12,45,66,77,33,44,22,99,10,11};
   int LeftOverArray[10];

   struct node *n;
   head=NULL;

   for(i=0;i<10;i++)
   {
       if(a[i]%3==0)
       {
           add(a[i]);
       }
       else
       {
           LetfOverArray[cc]=a[i];
           cc++;
       }                   }
}      


  

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