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

Create a C program following these guidelines: Create a Check node structure. In

ID: 3869730 • Letter: C

Question

Create a C program following these guidelines:

Create a Check node structure. Include:

Check number (should be an integer).

Date (use type char[ ]).

To

Amount

Description

Pointer to the next Check node

Add functions to:

Add a Check to the checkbook. Collect all information for a single check and add it to the checkbook. Call the function to display the values for the check before adding the check.

Delete a check from the checkbook. Use the check number to identify the check to be deleted.

Display the values for a single check. Format the amount for two decimal places.

Display the values for the entire checkbook, one check at a time.

In the main function:

Create a checkbook. It should be a linked list.

Repeat until the user quits. Give the user these options:

Add a check.

Delete a check.

Display a single check.

Display the checkbook.

Quit.

Explanation / Answer

#include<stdio.h>

#include <stdlib.h>

typedef struct node
{
int data;
struct node *link;
}node;
node*head;
void inserted()
{
printf("enter the number you want to enter in the check book ");
int n;
scanf("%d",&n);
node* temp = (node*) malloc(sizeof(node));
temp->data=n;
temp->link=NULL;
node*temp1=head;
if(head==NULL)
{

head=temp;
}
else
{

while(temp1->link!=NULL)
{

temp1=temp1->link;
}
temp1->link=temp;
}

}
void deleted()
{
printf("enter the postion you want to deletefrom check book ");
int x,i;
scanf("%d",&x);
x=x-1;
node*temp=head;
for( i=0;i<x-1;i++)
{
temp=temp->link;
}
if(x==0)
{
head=temp->link;
}
else
{
node* temp1=temp->link;
temp->link=temp1->link;
}
}

void print()
{
node*temp=head;
while(temp!=NULL)
{
printf("%d ",temp->data);
temp=temp->link;

}
}

void printe(int x)
{

node*temp=head;
while(--x)
{
temp=temp->link;

}
printf("%d ",temp->data);
}
int main()
{
int n,x,flag=1;
while(flag)
{
// cout<<"enter the given numbers for the following tasks to complete"<<endl;
printf("enter 1 ADD a check ");
printf("enter 2 DELETE a check ");
printf("enter 3 DISPLAY a single check ");
printf("enter 4 DISPLAY a check book ");
printf("enter 5 QUIT ");
//cout<<"enter 6 for reversing the number of elements"<<endl;
int n;
scanf("%d",&n);
switch(n)
{
case 1:
inserted();
break;
case 2:
deleted();
break;
case 3:
printf("enter the position you want to print ");
int x;
scanf("%d",&x);
printe(x);
break;
case 4:
print();
break;
case 5:
flag=0;
break;
default:
printf("enter the numbers given above ");
}
}
}

output:

enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
1
enter the number you want to enter in the check book
200
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
1
enter the number you want to enter in the check book
300
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
1
enter the number you want to enter in the check book
4000
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
1
enter the number you want to enter in the check book
500
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
4
200
300
4000
500
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
3
enter the position you want to print
3
4000
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
2
enter the postion you want to deletefrom check book
3
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
4
200
300
500
enter 1 ADD a check
enter 2 DELETE a check
enter 3 DISPLAY a single check
enter 4 DISPLAY a check book
enter 5 QUIT
5