Answer to Question #249888 in Databases | SQL | Oracle | MS Access for Tarurendra Kushwah

Question #249888

Write a program to multiply every element of the linked list with 10


1
Expert's answer
2021-10-13T03:50:59-0400
#include<iostream>
using namespace std;
class Node{
	public:
		int data;
		Node * next;
};


void  push(Node** head, int data)
{
   
    Node* node = new Node();
 
    
    node->data = data;
 
    
    node->next = (*head);
 
    
    (*head) = node;
    
    
}
void display(Node * node){
	while(node != NULL){
		cout<<node->data<<"  ";
		node = node->next;
	}
	cout<<endl;
}


void multiply(Node *node){
	while(node !=NULL){
		cout<<node->data * 10<<"  ";
		node = node->next;
	}
}
int main(){
	Node *list = NULL;
	push(&list,1);
	push(&list,3);
	push(&list,4);
	push(&list,5);
	cout<<"The elements of the linked list are:  ";
	display(list);
	cout<<"After multiplying every element in the linked list by 10:  ";
	multiply(list);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS