Wiki User
∙ 14y agoTo insert a value after a node in a linked list, first allocate and initialize the node, then add it to the current node...
newnode* = new node (n);
newnode->next = current.next;
if (current != head) current->next = newnode; else head = newnode;
Wiki User
∙ 14y agoWiki User
∙ 13y ago#include<iostream.h>
#include<conio.h>
#include<process.h>
class list
{
public:
int info;
list *link;
};
class link_list
{
public:
list *head;
link_list()
{
head=NULL;
}
void insertf();
void deletef();
void show();
};
void link_list::insertf()
{
int item;
list *temp;
cin>>item;
temp=new list;
temp->info=item;
temp->link=NULL;
if(head==NULL)
head=temp;
else
{
temp->link=head;
head=temp;
}
}
void link_list::deletef()
{
list *temp;
if(head==NULL)
{
cout<<"Deleted item is:"<<temp->info;
head=temp->link;
}
}
void link_list::show()
{
list *temp;
if(head==NULL)
cout<<"List is empty:";
else
{
temp=head;
while(temp!=NULL)
{
cout<<temp->info;
temp=temp->link;
}
}
}
void main()
{
int ch;
link_list l1;
clrscr();
do
{
cout<<"\n Press 1 foe insertion";
cout<<"\n Press 2 for deletion";
cout<<"\n Press 3 for show";
cout<<"\n Press 4 for exit";
cin>>ch;
switch(ch)
{
case 1:
l1.insertf();
break;
case 2:
l1.deletef();
break;
case 3:
l1.show();
break;
case 4:
cout<<"Exit";
break;
default:
cout<<"You have entered wrong choice";
break;
}
}while(ch=4);
getch();
}
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
Reference:cprogramming-bd.com/c_page3.aspx#calculates the value of money
pointer is a derived datatype which contains memory addresses as their values. program:- #include<stdio.h> #include<conio.h> void main() { int m=5,*p; clrscr(); p=&m; printf("address of variable m is %p",(void *)p); }
Yes, do that, because it is your homework.
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
There isn't a reason to write a complete program to do this; in any assembly language just shift the value 1 bit to the left to double it.
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.
Reference:cprogramming-bd.com/c_page3.aspx#calculates the value of money
pointer is a derived datatype which contains memory addresses as their values. program:- #include<stdio.h> #include<conio.h> void main() { int m=5,*p; clrscr(); p=&m; printf("address of variable m is %p",(void *)p); }
int square (int N) return N*N;
Yes, do that, because it is your homework.
It returns the value to the operating system or whatever process launched it. If you launched your program from a batch file then the batch file can detect this return value. If your program is spawned or launched by another program then the return value goes to that parent prgoram or process. One more thing is that you can write main() without the return type and it will be absolutely correct
question clarity
it means to write the value. for example.... 1.639. just write the value.
void foo (double val) { printf ("Full value: %f\n", val); printf ("Half value: %f\n", val/2); }