( Progrraming Lauguage , C++. Please Try and Provide me a complete programm Answ
ID: 3792291 • Letter: #
Question
( Progrraming Lauguage , C++. Please Try and Provide me a complete programm Answer. not just one or two function)
* Declare a single dimensional array of 65 characters. Convert each character into an integer and store it in a linked list. Manipulate the linked list by completing the following task:
Create an additional linked list call greater_List, using the original linked list copy all number greater than 100 into the greater_list and give a total count of the numbers greater than 100. Create an additional array called less_array, copy all the numbers less than or equal to 100 in the original list into less_array give a total count of the numbers that are less than or equal to 100.
Explanation / Answer
#include<stdio.h>
#include<iostream>
using namespace std;
struct node
{
int data;
struct node *next;
}*head,*head1;
void add(int[] arr) {
struct node *temp,*temp1;
for(int i=0;i<10;i++)
{
if(arr[i]>100)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=arr[i];
if (head== NULL)
{
head=temp;
head->next=NULL;
}else
{
temp->next=head;
head=temp;
}
}else
{
temp1=(struct node *)malloc(sizeof(struct node));
temp1->data=arr[i];
if (head== NULL)
{
head=temp1;
head->next=NULL;
}else
{
temp1->next=head;
head=temp1;
}
}
}
}
void display(struct node *r)
{
r=head;
if(r==NULL)
{
return;
}
while(r!=NULL)
{
printf("%d ",r->data);
r=r->next;
}
printf(" ");
}
int main()
{
struct node* head,*head1;
char array[10];
int array1[10];
char a='';
for(int i=0;i<10;i++)
{
cout<<"enter the characters"<<endl;
cin>>a;
int c=a;
array1[i]=c;
}
add(array1);
display(head);
display(head1);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.