SlideShare a Scribd company logo
1 of 26
Download to read offline
You are required to write an interactive C program that prompts the user for commands, accepts
commands from the keyboard (stdin) and executes those commands. When a command requires
output, it must be written to stdout. The program must continue to accept and process commands
until the user types the end command.
The program deals with linked lists. Each node of such a list contains a string of length at most
10, a positive integer (i.e., an integer value 1) and a pointer to the next node of the list. For any
node, the string and the integer stored in that node will be referred to as the symbol and count for
that node respectively. At all times, the list must satisfy the following two important properties.
1. The symbols appearing in the list are all distinct; that is, no two nodes have the same symbol.
2. When the list is scanned from left to right, the counts must be in non-increasing order.
Initially, we have an empty list. Some commands require your program to modify the list while
others involve traversing the list to gather and print information about the list. The commands
and their interpretations are as follows. (You should bear in mind that different parts of a
command are separated by one or more spaces.)
(a)Insert Command: The syntax for this command is as follows: ins str
Here, ins represents the name of the command and str represents a string. The interpretation of
this command is as follows.
(i) If the list contains a node whose symbol is identical to the string specified in the command,
then the count stored in the node must be incremented by 1. After this increment, if necessary,
the node must be moved to an appropriate position in the list to ensure that the counts are in non-
increasing order.
(ii) If the list does not contain a node whose symbol is identical to the string specified in the
command, then a new node must be created. The symbol stored in the new node is the string
specified in the command and the count stored in the new node must be 1. The new node must be
inserted at the end of the list.
Note that the ins command does not produce any output.
(b)Delete Command: The syntax for this command is as follows:
del str
Here, del represents the name of the command and str represents a string. The interpretation of
this command is as follows.
(i) If the list contains a node whose symbol is identical to the string specified in the command,
then the count stored in the node must be decremented by 1. If the new count becomes 0, then
the node must be removed from the list. If the new count is at least 1, the node must be moved, if
necessary, to an appropriate position in the list to ensure that the counts are in non-increasing
order.
(ii) If the list does not contain a node whose symbol is identical to the string specified in the
command, then your program must leave the list unchanged.
Note that the del command does not produce any output.
(c)Forced Delete Command: The syntax for this command is as follows:
fde val
Here, fde represents the name of the command and val represents a positive integer value. The
command must remove from the list, each node whose count is less than or equal to the integer
value specified by val. If the list is empty or the count stored in each node is greater than the
value
2
specified by val, then your program must leave the list unchanged. Note that the fde command
does not produce any output.
(d)Print Statistics Command: The syntax for this command is as follows: pst
Here, pst represents the name of the command. If the list is empty, your program should simply
print the message “The list is empty.”. Otherwise (i.e., the list is non-empty), your program must
compute and print the following quantities.
(a) The number of nodes in the list.
(b) The maximum count in the list.
(c) The minimum count in the list.
(d) The average count in the list. (Bear in mind that, in general, the average count is a real
number.)
(e)Print List Command: The syntax for this command is as follows: prl
Here, prl represents the name of the command. If the list is empty, your program should print the
message “The list is empty.”. Otherwise, your program should traverse the list (from left to right)
and print each symbol and the corresponding count on a line by itself. (Thus, when the list is
non-empty, the number of lines printed is the number of nodes in the list.)
(f)Print using Count Range Command: The syntax for this command is as follows: pcr v1 v2
Here, pcr represents the name of the command and v1 and v2 are non-negative integer values
such that the value specified by v1 is less than or equal to that specified by v2. If the list is
empty, your program should simply print the message “The list is empty.”. Otherwise, your
program should traverse the list (from left to right); for each node whose count is in the integer
range specified by v1 and v2 (i.e., the count is greater than or equal to the value specified by v1
and less than or equal to the value specified by v2 ), the program must print the symbol and the
count for that node on a line by itself. (Thus, when the list is non-empty, the number of lines
printed is the number of nodes in the list whose counts are in the integer range specified by v1
and v2.)
(g)Print Prefix Command: To discuss this command, we first note that a prefix is a substring that
occurs at the beginning of a string. For example, the string “val” is a prefix of the symbol
“value” and the string “On” is a prefix of the symbol “Only”. (Note also that each string is a
prefix of itself.) However, the string “alu” is not a prefix of the symbol “value” and the string
“ly” is not a prefix of the symbol “Only”.
3
The syntax for the print prefix command is as follows:
ppr str
Here, ppr represents the name of the command and str represents a string. If the list is empty,
your program should simply print the message “The list is empty.”. Otherwise, your program
should traverse the list (from left to right); if the given string str is a prefix of the symbol stored
in a node, then the command must print the symbol and the corresponding count on a line by
itself. (Thus, when the list is non-empty, the number of lines printed is the number of symbols
which have the string specified by str as a prefix.)
(h)Print Suffix Command: To discuss this command, we first note that a suffix is a substring that
occurs at the end of a string. For example, the string “ue” is a suffix of the symbol “value” and
the string “y” is a suffix of the symbol “Only”. (Note also that each string is a suffix of itself.)
However, the string “va” is not a suffix of the symbol “value” and the string “nl” is not a suffix
of the symbol “Only”.
The syntax for the command is as follows:
psu str
Here, psu represents the name of the command and str represents a string. If the list is empty,
your program should print the message “The list is empty.”. Otherwise, your program should
traverse the list (from left to right); if the given string str is a suffix of the symbol stored in a
node, then the command must print the symbol and the corresponding count on a line by itself.
(Thus, when the list is non-empty, the number of lines printed is the number of symbols which
have the string specified by str as a suffix.)
(i)End Command: The syntax for this command is as follows: end
In response to this command, your program must stop.
Assumptions: In writing this program, you may assume the following.
(a) Symbols, prefixes, suffixes are all case sensitive. (Thus, the symbols “value” and “Value” are
distinct. The string “val” is a prefix of the symbol “value” but not a prefix of the symbol
“Value”. Similar considerations apply to suffixes.)
(b) The command given by the user will be one of ins, del, fde, pst, prl, pcr, ppr, psu or end. (The
command names are also case sensitive.)
(c) Each command will contain all and only the necessary arguments. (Thus, commands won’t
have missing or extraneous arguments.) Further, when a command has one or more arguments,
the command name and the successive arguments will be separated by one or more spaces.
(d) Each string specified in a command will have a length of at least 1 and at most 10; further,
the string won’t include any whitespace characters.
4
(e) Integer values specified in commands will be non-negative; further, in the pcr command, the
value specified by v1 will be less than or equal to that specified by v2.
Thus, there is no need to deal with any erroneous commands. Your program should continue to
prompt the user and process commands until the user types the end command.
Here is a snippet of the code
//char declerations for all commands
//str1 //= to input command
#include
struct node
{
int data;
struct node *next;
}*head;
void main(void){
char ins[3]="ins";
char del[3]="del";
char fde[3]="fde";
char pst[3]="pst";
char prl[3]="prl";
char pcr[3]="pcr";
char ppr[3]="ppr";
char psu[3]="psu";
char end[3]="end";
char str1[10];
char secondarycommand[10];
//accept first input here
printf("Enter command:  ");
scanf("%c %c", &str1, &secondarycommand);
//accepts input as two strings, can parse to int later depending on the command
int tester;
int end1=0;
while(end1 !=1){
tester = strcmp(str1, ins);
if (tester ==0){
// insert
}
tester = strcmp(str1, del);
if (tester ==0){
// delete
}
tester = strcmp(str1, fde);
if (tester ==0){
// force delete
}
tester = strcmp(str1, pst);
if (tester ==0){
//print statistics
}
tester = strcmp(str1, prl);
if (tester ==0){
// print list
}
tester = strcmp(str1, pcr);
if (tester ==0){
// Print Count Range
}
tester = strcmp(str1, ppr);
if (tester ==0){
// Print Prefix
}
tester = strcmp(str1, psu);
if (tester ==0){
//Print Suffix
}
tester = strcmp(str1, end);
if (tester ==0){
end1=1;
exit(0);
//end
}
else{
printf("unknown command ");
end1=1;
exit(0);
}
//accept next input here
printf("Enter next command:  ");
scanf("%c %d", &str1, &secondarycommand);
//accepts input as two strings, can parse to int later depending on the command
}
return 0;
}
Solution
#include
#include
#include
#define STRING_SIZE 11
/* Size of char array for the string */
#define COMMAND_SIZE 4
/* Size of char array for the command*/
#define PREFIX_SIZE 11
/* Size of char array for prefix */
#define SUFFIX_SIZE 11
/* Size of char array for suffix */
#define COMPARE_TO 3
/* Number of spots to compare command up until */
#define FIRST_COUNT 1
/* Sets count to 1 */
#define SORT 1
/* Used to determine whether to sort list or not */
#define DONT_SORT 0
/* Used to determine whether to sort list or not */
#define LARGE_NUM 100000
/* Array size for int array for count in printStats */
#define ONE 1
/* Used in calculations */
/* Function Prototypes */
void insert(char[STRING_SIZE]);
void createNewList(char[STRING_SIZE]);
void delete(char[STRING_SIZE], int);
void forcedDelete(int);
void sortList();
int printStats();
void printList();
int printByCount(int, int);
void printPrefix(char[PREFIX_SIZE]);
void printSuffix(char[SUFFIX_SIZE]);
/* Function Prototypes */
/* Explainations are within the function themselves */
typedef struct LinkedList
/* Structrure definition for the linked list nodes */
{
char symbol[STRING_SIZE]; /* String in node */
int count; /* Count of node */
struct LinkedList *next;
} Node;
/* Struct for nodes of the linked list */
Node *pHead = NULL;
/* Pointer to head node */
Node *pTail = NULL;
/* Pointer to tail node */
/* Pointers to the node */
int main(void)
/* Main function */
{
char command[COMMAND_SIZE];
/* char array to store command */
char string[STRING_SIZE];
/* char array to store string */
char ins[] = "ins";
/* string command ins to commpare */
char del[] = "del";
/* string command del to commpare */
char fde[] = "fde";
/* string command fde to commpare */
char prl[] = "prl";
/* string command prl to commpare */
char end[] = "end";
/* string command end to commpare */
char pcr[] = "pcr";
/* string command pcr to commpare */
char pst[] = "pst";
/* string command pst to commpare */
char ppr[] = "ppr";
/* string command ppr to commpare */
char psu[] = "psu";
/* string command psu to commpare */
char pre[PREFIX_SIZE];
/* char array for user entered prefix */
char suf[SUFFIX_SIZE];
/* char array for user entered suffix */
int val;
/* value to print range */
int val2;
/* value to print range */
printf("Enter a command: "); fflush(stdout);
scanf("%s", command);
while (strcmp(command, end) != 0)
/* Run while command doesn't equal "end" */
{
if (strcmp(command, ins) == 0)
/* Do this if user enters ins for insert */
{
scanf("%s", string);
/* input string */
insert(string);
/* call insert function */
}
else if (strcmp(command, del) == 0)
/* Do this if user enters del */
{
scanf("%s", string);
/* input string */
delete(string, SORT);
/* call delete function */
}
else if (strcmp(command, fde) == 0)
/* Do this if user enters fde */
{
scanf("%d", &val);
/* input int to force delete from */
forcedDelete(val);
/* call forcedelete function */
}
else if (strcmp(command, prl) == 0)
/* Do this if user enters prl */
{
printList();
/* call printList function */
}
else if (strcmp(command, pcr) == 0)
/* Do this if user enters pcr */
{
scanf("%d", &val);
/* input int to print count from */
scanf("%d", &val2);
/* input int to print count up until */
printByCount(val, val2);
/* call printByCount function */
}
else if (strcmp(command, pst) == 0)
/* Do this if users enters pst */
{
printStats();
/* Call printStats function */
}
else if (strcmp(command, ppr) == 0)
/* Do this if user enters ppr */
{
scanf("%s", pre);
/* input string into prefix variable */
printPrefix(pre);
/* call printPrefix function */
}
else if (strcmp(command, psu) == 0)
/* Do this if user enters psu */
{
scanf("%s", suf);
/* input string into suffix variable */
printSuffix(suf);
/* call printSuffix function */
}
printf(" Enter a command: "); fflush(stdout);
scanf("%s", command);
/* Prompt user to enter a command and
* input command into string
*/
}
if (strcmp(command, end) == 0)
/* Do this if user inputs "end" */
{
printf(" Program Closing "); fflush(stdout);
}
}
void insert(char string[STRING_SIZE])
{
Node *pNewNode = malloc(sizeof(Node));
Node *pLoop = pHead;
if (pHead == NULL)
{
createNewList(string);
/* Call create newList function */
}
else
{
strcpy(pNewNode -> symbol, string);
if (pHead == pTail)
{
if (strcmp(pHead -> symbol, pNewNode -> symbol) == 0)
/* Do this if the second node being input equals head node */
{
pHead -> count++;
/* Increment head count by one */
}
else
{
pNewNode -> count = FIRST_COUNT;
pHead -> next = pNewNode;
/* Have the head node point to the new node */
pTail = pNewNode;
/* Insert the new node into tail */
pNewNode -> next = NULL;
/* Remove the new from the list */
}
}
else
{
while (pLoop != NULL)
/* run while node does not equal null */
{
if (strcmp(pLoop -> symbol, pNewNode -> symbol) == 0)
/* Do this if new node symbol equals current node symbol */
{
pLoop -> count++;
/* Increment current node count by one */
break;
/* break out of loop */
}
else if (pLoop -> next == NULL)
/* Do this if next node equals null */
{
pNewNode -> count = FIRST_COUNT;
pTail -> next = pNewNode;
/* Point the tail node to the new node */
pNewNode -> next = NULL;
/* Remove the new node frome the list */
pTail = pNewNode;
/* Insert the new node into tail */
break;
}
pLoop = pLoop -> next;
/* increment linked list */
}
}
sortList();
/* call sortList function */
}
}
void createNewList(char string[STRING_SIZE])
/* Function to create a new list */
{
Node *pNewNode = malloc(sizeof(Node));
pNewNode -> next = NULL;
strcpy(pNewNode -> symbol, string);
/* Insert user's string into node */
pNewNode -> count = FIRST_COUNT;
pHead = pTail = pNewNode;
}
void delete(char string[STRING_SIZE], int sort)
/* Function to delete a node */
{
Node *pCurr = pHead;
Node *pPrev = NULL;
if (pHead == NULL)
{
printf("This List Is Empty "); fflush(stdout);
}
while (pCurr != NULL)
{
if (strcmp(pCurr -> symbol, string) == 0)
/* Do this if the current nodes symbol equals user inputed string */
{
if (pCurr -> count > 1)
/* If current node has a count greater than one*/
{
pCurr -> count--;
/* Decrement current node count by one */
}
else
{
if (pCurr == pHead)
{
pHead = pCurr -> next;
free(pCurr);
/*
* Free original head node from memory.
*/
}
else
{
if ((pPrev == pHead) && (pCurr -> next == NULL))
{
pTail = pHead;
pHead -> next = NULL;
}
else if (pCurr -> next == NULL)
/* If the next node equals null */
{
pTail = pPrev;
/* Make tail node the previous node */
pTail -> next = NULL;
/* Have tail reference null */
free(pCurr);
/* free current node from memory */
}
else
{
pPrev -> next = pCurr -> next;
free(pCurr);
/*
* Free removed node from memory.
*/
}
}
}
}
pPrev = pCurr;
/* have the current node equal previous node */
pCurr = pCurr -> next;
/* Increment current node */
}
if (sort == 1)
{
sortList();
/* Call sortList function */
}
}
void printList()
/* printList function */
{
Node *pCurr = pHead;
if (pHead == NULL)
/* If head node equals null */
{
printf("The list is empty. "); fflush(stdout);
}
else
{
printf(" Strings Entered: "); fflush(stdout);
printf(" "); fflush(stdout);
while (pCurr != NULL)
/* run while current node isn't null */
{
printf("%s", pCurr -> symbol); fflush(stdout);
printf(" %d ", pCurr -> count); fflush(stdout);
/* Print symbol and count from current node */
pCurr = pCurr -> next;
/* Move to next node */
}
}
}
void forcedDelete(int min)
/* function to delete nodes based on count */
{
Node *pCurr = pHead;
int nodeCount;
if (pHead == NULL)
{
printf("This List Is Empty "); fflush(stdout);
}
while(pCurr != NULL)
/* run while current node isn't null */
{
nodeCount = pCurr -> count;
/* insert current nodes count into int variable */
if (nodeCount <= min)
/* if nodeCount is less than min */
{
while(nodeCount > 0)
/* Run while nodeCount is greater than zero */
{
nodeCount--;
/* decrement nodeCount by one */
delete(pCurr -> symbol, DONT_SORT);
/* Call delete function with current symbol and don't sort list */
}
}
pCurr = pCurr -> next;
/* move to next node */
}
}
void sortList()
/* Function to sort the list */
{
Node *pCurr = pHead;
Node *pNext = NULL;
Node *pPrev = NULL;
while (pCurr != NULL)
/* Run while current node isn't null */
{
pNext = pCurr -> next;
/* set the next node */
if (pPrev == NULL)
/* Check to see if it the head node */
{
if (pNext == NULL);
/* if next equals null, */
else if (pCurr -> count < pNext -> count)
{
if (pNext -> next == NULL)
/*
* If there are only 2 nodes in the linked list
*/
{
pCurr -> next = pNext -> next;
/* Set current reference to next reference */
pHead = pNext;
/* Set next node equal to head */
pTail = pCurr;
/* Set current equal to tail */
pHead -> next = pTail;
/* have head node reference tail */
}
else
/*
* If there are more than 2 nodes in the linked list
*/
{
pCurr -> next = pNext -> next;
/* Set current reference to next referenec */
pHead = pNext;
/* Set next node equal to head */
pHead -> next = pCurr;
/* have head equal current node */
sortList();
/* call sortList again to continue sorting */
}
}
}
else if (pNext == NULL)
/* Do this if next node equals null */
{
break;
/* break out of loop */
}
else if (pCurr -> count < pNext -> count)
/* do this if current count is less than next count */
{
if (pNext -> next == NULL)
/*
* If there are only 2 nodes in the linked list
*/
{
pCurr -> next = pNext -> next;
/* have current node reference the node next is pointing to */
pPrev -> next = pNext;
/* have previous node reference the next node */
pTail = pCurr;
/* insert current node into tail node */
pNext -> next = pCurr;
/* have next node reference current node */
sortList();
/* call sortList function to continue sorting list */
}
else
{
pPrev -> next = pNext;
/* have previous node reference next node */
pCurr -> next = pNext -> next;
/* have current node reference node the next node is referencing */
pNext -> next = pCurr;
/* have next node reference the current node */
sortList();
/* call sortList function to continue sorting list */
}
}
pPrev = pCurr;
/* have previous node equal current node */
pCurr = pCurr -> next;
/* move to next node */
}
}
int printByCount(int v1, int v2)
/* function to print out nodes between the range of the inputed count values */
{
Node *pCurr;
/* node pointer for current node */
int nodeCount;
/* int variable for node count */
if(pHead == NULL)
/* do this if head is null */
{
printf("%s ","The list is empty"); fflush(stdout);
return 0;
/* leave function */
}
pCurr = pHead;
printf(" "); fflush(stdout);
while(pCurr != NULL)
/* loop through list while current doesn't equal null */
{
nodeCount = pCurr -> count;
/* insert current node count into nodeCount variables */
if(nodeCount >= v1 && nodeCount <= v2)
{
printf("%s",pCurr -> symbol); fflush(stdout);
printf(" %d ", pCurr -> count); fflush(stdout);
/* print node */
}
pCurr = pCurr -> next;
/* move to next node */
}
return 0;
}
int printStats()
/* function to print stats of nodes */
{
Node *pCurr;
/* pointer to current node */
int min = LARGE_NUM;
/* minimum value */
int max = 0;
/* max value */
double mean = 0;
/* mean value */
int numCount = 0;
/* count value */
int nodeCount;
/* count value */
int numCount2;
/* count value */
int allCounts[LARGE_NUM];
/* array of all counts */
if(pHead == NULL)
/* if list is empty */
{
printf("%s ","The list is empty."); fflush(stdout);
return 0;
/* leave function */
}
pCurr = pHead;
/* insert head node into current */
while(pCurr != NULL)
/* run while there are nodes in the linked list */
{
nodeCount = pCurr -> count;
/* set nodeCount to current count */
numCount++;
/* increment numCount by one */
if(nodeCount > max)
/* if nodeCount is greater than the max value */
{
max = nodeCount;
/* Set max value to current nodeCount */
}
if(nodeCount < min)
/* If nodeCount is less than the max value */
{
min = nodeCount;
/* Set min value to current nodeCount */
}
allCounts[numCount - ONE] = nodeCount;
/* Insert nodeCount into allCounts array at next available position */
pCurr = pCurr -> next;
/* Set current node to next node */
}
numCount2 = numCount;
/* Insert numCount into numCount2 */
while(numCount2 > -ONE)
/* run while numCount2 is greater than negative one */
{
mean = mean + allCounts[numCount2 - ONE];
/* adds total count to mean to be calculated */
numCount2--;
/* decrement numCount2 by one */
}
mean = mean / numCount;
/* Calculates mean */
printf(" "); fflush(stdout);
printf("%s","The number of nodes in the list: "); fflush(stdout);
printf("%d ",numCount); fflush(stdout);
/* Prints the number of nodes in the list */
printf("%s","The maximum count in the list: "); fflush(stdout);
printf("%d ",max); fflush(stdout);
/* Prints the maximum count in the list */
printf("%s","The minimum count in the list: "); fflush(stdout);
printf("%d ",min); fflush(stdout);
/* prints the minimum count in the list */
printf("%s","The mean of the list's count values: "); fflush(stdout);
printf("%f ",mean); fflush(stdout);
/* prints the mean of all the counts in the list */
return 0;
/* return to main function */
}
void printPrefix(char pre[PREFIX_SIZE])
/* Function to print prefix */
{
Node *pCurr = pHead;
if (pHead == NULL)
/* Run if the list is empty */
{
printf("The List Is Empty "); fflush(stdout);
}
else
{
printf(" "); fflush(stdout);
while (pCurr != NULL)
{
if (strstr(pCurr -> symbol, pre) != NULL)
/* Runs if the prefix the user inputs is in the current node */
{
if ((strcspn(pCurr -> symbol, pre) == 0) || (strncmp(pCurr -> symbol, pre, 3) == 0))
{
printf("%s", pCurr -> symbol); fflush(stdout);
printf(" %d ", pCurr -> count); fflush(stdout);
/* Print string and count of string */
}
}
pCurr = pCurr -> next;
/* move to next node */
}
}
}
void printSuffix(char suf[SUFFIX_SIZE])
{
int sufLen = 0;
int symLen = 0;
int index = 0;
int nineNineK;
/* integers used for string manipulations */
char endSym[LARGE_NUM];
Node *pCurr;
/* pointer to a node; this is used to walk across the list */
if(pHead == NULL)
/* prints "the list is empty if the first node in the list is NULL */
{
printf("%s ", "The list is empty"); fflush(stdout);
}
else
{
pCurr = pHead;
/* sets node to first node in list */
printf(" ");
while(pCurr != NULL)
/* loops while nodes remain */
{
index = 0;
nineNineK = LARGE_NUM - ONE;
/* resetting variables used to keep track of positions in arrays */
while(nineNineK > - ONE)
/* this loop sets every position of char array to '0' */
{
endSym[nineNineK] = '0';
nineNineK = nineNineK - ONE;
}
symLen = (int)(strlen(pCurr -> symbol));
sufLen = (int)strlen(suf);
/* gets length of symbol and passed string */
while(sufLen > 0)
/* adds last n characters to new array to compare */
{
endSym[index] = pCurr->symbol[symLen-sufLen];
sufLen = sufLen - 1;
index = index + 1;
}
if(strstr(endSym, suf) != NULL)
{
printf("%s",pCurr-> symbol); fflush(stdout);
printf(" %d ", pCurr-> count); fflush(stdout);
}
pCurr = pCurr-> next;
/* moves to next node in list */
}
}
}

More Related Content

Similar to You are required to write an interactive C program that prompts the .pdf

Write a parallel program using MPI and not OpeMP to accomp.pdf
Write a parallel program using MPI and not OpeMP to accomp.pdfWrite a parallel program using MPI and not OpeMP to accomp.pdf
Write a parallel program using MPI and not OpeMP to accomp.pdfaaryanentp
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filtersbhatvijetha
 
Doscommands
DoscommandsDoscommands
DoscommandsDurgule
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYRajeshkumar Reddy
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxdelciegreeks
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lispLISP Content
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsRai University
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-aneebkmct
 
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfUsing the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfamirthagiftsmadurai
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and stringsRai University
 

Similar to You are required to write an interactive C program that prompts the .pdf (20)

Write a parallel program using MPI and not OpeMP to accomp.pdf
Write a parallel program using MPI and not OpeMP to accomp.pdfWrite a parallel program using MPI and not OpeMP to accomp.pdf
Write a parallel program using MPI and not OpeMP to accomp.pdf
 
Strings
StringsStrings
Strings
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Doscommands
DoscommandsDoscommands
Doscommands
 
Doscommands
DoscommandsDoscommands
Doscommands
 
Ch09
Ch09Ch09
Ch09
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
C programming part4
C programming part4C programming part4
C programming part4
 
C programming part4
C programming part4C programming part4
C programming part4
 
paython practical
paython practical paython practical
paython practical
 
I have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docxI have question in c++ program I need the answer as soon as possible.docx
I have question in c++ program I need the answer as soon as possible.docx
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
 
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfUsing the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 

More from arrowcomputers8700

How are control charts madeSolutionThe control chart is a gra.pdf
How are control charts madeSolutionThe control chart is a gra.pdfHow are control charts madeSolutionThe control chart is a gra.pdf
How are control charts madeSolutionThe control chart is a gra.pdfarrowcomputers8700
 
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdfGENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdfarrowcomputers8700
 
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdf
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdfFigure 5.2 shows a common biological phospholipid called phosphatidy.pdf
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdfarrowcomputers8700
 
Discuss the relationship between some of the common file classes in .pdf
Discuss the relationship between some of the common file classes in .pdfDiscuss the relationship between some of the common file classes in .pdf
Discuss the relationship between some of the common file classes in .pdfarrowcomputers8700
 
describe the cell categories of nervous tissue and describe the orga.pdf
describe the cell categories of nervous tissue and describe the orga.pdfdescribe the cell categories of nervous tissue and describe the orga.pdf
describe the cell categories of nervous tissue and describe the orga.pdfarrowcomputers8700
 
Describe what is meant by the Internet of Things. What industrie.pdf
Describe what is meant by the Internet of Things. What industrie.pdfDescribe what is meant by the Internet of Things. What industrie.pdf
Describe what is meant by the Internet of Things. What industrie.pdfarrowcomputers8700
 
Create a class named Person. The person class contains first name, .pdf
Create a class named Person. The person class contains first name, .pdfCreate a class named Person. The person class contains first name, .pdf
Create a class named Person. The person class contains first name, .pdfarrowcomputers8700
 
C++ Programming Language N-number queue rotations.Write methods v.pdf
C++ Programming Language N-number queue rotations.Write methods v.pdfC++ Programming Language N-number queue rotations.Write methods v.pdf
C++ Programming Language N-number queue rotations.Write methods v.pdfarrowcomputers8700
 
Assume a disease is dominant, indicated by shading. Based on the pedi.pdf
Assume a disease is dominant, indicated by shading. Based on the pedi.pdfAssume a disease is dominant, indicated by shading. Based on the pedi.pdf
Assume a disease is dominant, indicated by shading. Based on the pedi.pdfarrowcomputers8700
 
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdf
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdfChorismate 3-glycero phosphate Relying on the above pathway for b.pdf
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdfarrowcomputers8700
 
A form of favoritism where you give preferential treatment to your f.pdf
A form of favoritism where you give preferential treatment to your f.pdfA form of favoritism where you give preferential treatment to your f.pdf
A form of favoritism where you give preferential treatment to your f.pdfarrowcomputers8700
 
2.Describe a technique that would allow a developmental biologist to.pdf
2.Describe a technique that would allow a developmental biologist to.pdf2.Describe a technique that would allow a developmental biologist to.pdf
2.Describe a technique that would allow a developmental biologist to.pdfarrowcomputers8700
 
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdfarrowcomputers8700
 
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdf
Which plant cell organelle contains its own DNA and ribosome  A) Golg.pdfWhich plant cell organelle contains its own DNA and ribosome  A) Golg.pdf
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdfarrowcomputers8700
 
A living plant leaf is an open system that exchanges energy (sunligh.pdf
A living plant leaf is an open system that exchanges energy (sunligh.pdfA living plant leaf is an open system that exchanges energy (sunligh.pdf
A living plant leaf is an open system that exchanges energy (sunligh.pdfarrowcomputers8700
 
Which of the following are typically used as input devices A. Print.pdf
Which of the following are typically used as input devices  A. Print.pdfWhich of the following are typically used as input devices  A. Print.pdf
Which of the following are typically used as input devices A. Print.pdfarrowcomputers8700
 
What is dynamic semantics Can you please explain the many kinds of .pdf
What is dynamic semantics Can you please explain the many kinds of .pdfWhat is dynamic semantics Can you please explain the many kinds of .pdf
What is dynamic semantics Can you please explain the many kinds of .pdfarrowcomputers8700
 
What happened to Mexicans in the west after the US annexed their lan.pdf
What happened to Mexicans in the west after the US annexed their lan.pdfWhat happened to Mexicans in the west after the US annexed their lan.pdf
What happened to Mexicans in the west after the US annexed their lan.pdfarrowcomputers8700
 
What are pivot tablesWhat is the table format and how can it save.pdf
What are pivot tablesWhat is the table format and how can it save.pdfWhat are pivot tablesWhat is the table format and how can it save.pdf
What are pivot tablesWhat is the table format and how can it save.pdfarrowcomputers8700
 
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdfTopology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdfarrowcomputers8700
 

More from arrowcomputers8700 (20)

How are control charts madeSolutionThe control chart is a gra.pdf
How are control charts madeSolutionThe control chart is a gra.pdfHow are control charts madeSolutionThe control chart is a gra.pdf
How are control charts madeSolutionThe control chart is a gra.pdf
 
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdfGENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
 
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdf
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdfFigure 5.2 shows a common biological phospholipid called phosphatidy.pdf
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdf
 
Discuss the relationship between some of the common file classes in .pdf
Discuss the relationship between some of the common file classes in .pdfDiscuss the relationship between some of the common file classes in .pdf
Discuss the relationship between some of the common file classes in .pdf
 
describe the cell categories of nervous tissue and describe the orga.pdf
describe the cell categories of nervous tissue and describe the orga.pdfdescribe the cell categories of nervous tissue and describe the orga.pdf
describe the cell categories of nervous tissue and describe the orga.pdf
 
Describe what is meant by the Internet of Things. What industrie.pdf
Describe what is meant by the Internet of Things. What industrie.pdfDescribe what is meant by the Internet of Things. What industrie.pdf
Describe what is meant by the Internet of Things. What industrie.pdf
 
Create a class named Person. The person class contains first name, .pdf
Create a class named Person. The person class contains first name, .pdfCreate a class named Person. The person class contains first name, .pdf
Create a class named Person. The person class contains first name, .pdf
 
C++ Programming Language N-number queue rotations.Write methods v.pdf
C++ Programming Language N-number queue rotations.Write methods v.pdfC++ Programming Language N-number queue rotations.Write methods v.pdf
C++ Programming Language N-number queue rotations.Write methods v.pdf
 
Assume a disease is dominant, indicated by shading. Based on the pedi.pdf
Assume a disease is dominant, indicated by shading. Based on the pedi.pdfAssume a disease is dominant, indicated by shading. Based on the pedi.pdf
Assume a disease is dominant, indicated by shading. Based on the pedi.pdf
 
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdf
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdfChorismate 3-glycero phosphate Relying on the above pathway for b.pdf
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdf
 
A form of favoritism where you give preferential treatment to your f.pdf
A form of favoritism where you give preferential treatment to your f.pdfA form of favoritism where you give preferential treatment to your f.pdf
A form of favoritism where you give preferential treatment to your f.pdf
 
2.Describe a technique that would allow a developmental biologist to.pdf
2.Describe a technique that would allow a developmental biologist to.pdf2.Describe a technique that would allow a developmental biologist to.pdf
2.Describe a technique that would allow a developmental biologist to.pdf
 
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
 
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdf
Which plant cell organelle contains its own DNA and ribosome  A) Golg.pdfWhich plant cell organelle contains its own DNA and ribosome  A) Golg.pdf
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdf
 
A living plant leaf is an open system that exchanges energy (sunligh.pdf
A living plant leaf is an open system that exchanges energy (sunligh.pdfA living plant leaf is an open system that exchanges energy (sunligh.pdf
A living plant leaf is an open system that exchanges energy (sunligh.pdf
 
Which of the following are typically used as input devices A. Print.pdf
Which of the following are typically used as input devices  A. Print.pdfWhich of the following are typically used as input devices  A. Print.pdf
Which of the following are typically used as input devices A. Print.pdf
 
What is dynamic semantics Can you please explain the many kinds of .pdf
What is dynamic semantics Can you please explain the many kinds of .pdfWhat is dynamic semantics Can you please explain the many kinds of .pdf
What is dynamic semantics Can you please explain the many kinds of .pdf
 
What happened to Mexicans in the west after the US annexed their lan.pdf
What happened to Mexicans in the west after the US annexed their lan.pdfWhat happened to Mexicans in the west after the US annexed their lan.pdf
What happened to Mexicans in the west after the US annexed their lan.pdf
 
What are pivot tablesWhat is the table format and how can it save.pdf
What are pivot tablesWhat is the table format and how can it save.pdfWhat are pivot tablesWhat is the table format and how can it save.pdf
What are pivot tablesWhat is the table format and how can it save.pdf
 
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdfTopology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
 

Recently uploaded

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 

Recently uploaded (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

You are required to write an interactive C program that prompts the .pdf

  • 1. You are required to write an interactive C program that prompts the user for commands, accepts commands from the keyboard (stdin) and executes those commands. When a command requires output, it must be written to stdout. The program must continue to accept and process commands until the user types the end command. The program deals with linked lists. Each node of such a list contains a string of length at most 10, a positive integer (i.e., an integer value 1) and a pointer to the next node of the list. For any node, the string and the integer stored in that node will be referred to as the symbol and count for that node respectively. At all times, the list must satisfy the following two important properties. 1. The symbols appearing in the list are all distinct; that is, no two nodes have the same symbol. 2. When the list is scanned from left to right, the counts must be in non-increasing order. Initially, we have an empty list. Some commands require your program to modify the list while others involve traversing the list to gather and print information about the list. The commands and their interpretations are as follows. (You should bear in mind that different parts of a command are separated by one or more spaces.) (a)Insert Command: The syntax for this command is as follows: ins str Here, ins represents the name of the command and str represents a string. The interpretation of this command is as follows. (i) If the list contains a node whose symbol is identical to the string specified in the command, then the count stored in the node must be incremented by 1. After this increment, if necessary, the node must be moved to an appropriate position in the list to ensure that the counts are in non- increasing order. (ii) If the list does not contain a node whose symbol is identical to the string specified in the command, then a new node must be created. The symbol stored in the new node is the string specified in the command and the count stored in the new node must be 1. The new node must be inserted at the end of the list. Note that the ins command does not produce any output. (b)Delete Command: The syntax for this command is as follows: del str Here, del represents the name of the command and str represents a string. The interpretation of this command is as follows. (i) If the list contains a node whose symbol is identical to the string specified in the command, then the count stored in the node must be decremented by 1. If the new count becomes 0, then the node must be removed from the list. If the new count is at least 1, the node must be moved, if necessary, to an appropriate position in the list to ensure that the counts are in non-increasing order.
  • 2. (ii) If the list does not contain a node whose symbol is identical to the string specified in the command, then your program must leave the list unchanged. Note that the del command does not produce any output. (c)Forced Delete Command: The syntax for this command is as follows: fde val Here, fde represents the name of the command and val represents a positive integer value. The command must remove from the list, each node whose count is less than or equal to the integer value specified by val. If the list is empty or the count stored in each node is greater than the value 2 specified by val, then your program must leave the list unchanged. Note that the fde command does not produce any output. (d)Print Statistics Command: The syntax for this command is as follows: pst Here, pst represents the name of the command. If the list is empty, your program should simply print the message “The list is empty.”. Otherwise (i.e., the list is non-empty), your program must compute and print the following quantities. (a) The number of nodes in the list. (b) The maximum count in the list. (c) The minimum count in the list. (d) The average count in the list. (Bear in mind that, in general, the average count is a real number.) (e)Print List Command: The syntax for this command is as follows: prl Here, prl represents the name of the command. If the list is empty, your program should print the message “The list is empty.”. Otherwise, your program should traverse the list (from left to right) and print each symbol and the corresponding count on a line by itself. (Thus, when the list is non-empty, the number of lines printed is the number of nodes in the list.) (f)Print using Count Range Command: The syntax for this command is as follows: pcr v1 v2 Here, pcr represents the name of the command and v1 and v2 are non-negative integer values such that the value specified by v1 is less than or equal to that specified by v2. If the list is empty, your program should simply print the message “The list is empty.”. Otherwise, your program should traverse the list (from left to right); for each node whose count is in the integer range specified by v1 and v2 (i.e., the count is greater than or equal to the value specified by v1 and less than or equal to the value specified by v2 ), the program must print the symbol and the count for that node on a line by itself. (Thus, when the list is non-empty, the number of lines printed is the number of nodes in the list whose counts are in the integer range specified by v1 and v2.)
  • 3. (g)Print Prefix Command: To discuss this command, we first note that a prefix is a substring that occurs at the beginning of a string. For example, the string “val” is a prefix of the symbol “value” and the string “On” is a prefix of the symbol “Only”. (Note also that each string is a prefix of itself.) However, the string “alu” is not a prefix of the symbol “value” and the string “ly” is not a prefix of the symbol “Only”. 3 The syntax for the print prefix command is as follows: ppr str Here, ppr represents the name of the command and str represents a string. If the list is empty, your program should simply print the message “The list is empty.”. Otherwise, your program should traverse the list (from left to right); if the given string str is a prefix of the symbol stored in a node, then the command must print the symbol and the corresponding count on a line by itself. (Thus, when the list is non-empty, the number of lines printed is the number of symbols which have the string specified by str as a prefix.) (h)Print Suffix Command: To discuss this command, we first note that a suffix is a substring that occurs at the end of a string. For example, the string “ue” is a suffix of the symbol “value” and the string “y” is a suffix of the symbol “Only”. (Note also that each string is a suffix of itself.) However, the string “va” is not a suffix of the symbol “value” and the string “nl” is not a suffix of the symbol “Only”. The syntax for the command is as follows: psu str Here, psu represents the name of the command and str represents a string. If the list is empty, your program should print the message “The list is empty.”. Otherwise, your program should traverse the list (from left to right); if the given string str is a suffix of the symbol stored in a node, then the command must print the symbol and the corresponding count on a line by itself. (Thus, when the list is non-empty, the number of lines printed is the number of symbols which have the string specified by str as a suffix.) (i)End Command: The syntax for this command is as follows: end In response to this command, your program must stop. Assumptions: In writing this program, you may assume the following. (a) Symbols, prefixes, suffixes are all case sensitive. (Thus, the symbols “value” and “Value” are distinct. The string “val” is a prefix of the symbol “value” but not a prefix of the symbol “Value”. Similar considerations apply to suffixes.) (b) The command given by the user will be one of ins, del, fde, pst, prl, pcr, ppr, psu or end. (The command names are also case sensitive.) (c) Each command will contain all and only the necessary arguments. (Thus, commands won’t
  • 4. have missing or extraneous arguments.) Further, when a command has one or more arguments, the command name and the successive arguments will be separated by one or more spaces. (d) Each string specified in a command will have a length of at least 1 and at most 10; further, the string won’t include any whitespace characters. 4 (e) Integer values specified in commands will be non-negative; further, in the pcr command, the value specified by v1 will be less than or equal to that specified by v2. Thus, there is no need to deal with any erroneous commands. Your program should continue to prompt the user and process commands until the user types the end command. Here is a snippet of the code //char declerations for all commands //str1 //= to input command #include struct node { int data; struct node *next; }*head; void main(void){ char ins[3]="ins"; char del[3]="del"; char fde[3]="fde"; char pst[3]="pst"; char prl[3]="prl"; char pcr[3]="pcr"; char ppr[3]="ppr"; char psu[3]="psu"; char end[3]="end"; char str1[10]; char secondarycommand[10]; //accept first input here printf("Enter command: "); scanf("%c %c", &str1, &secondarycommand); //accepts input as two strings, can parse to int later depending on the command
  • 5. int tester; int end1=0; while(end1 !=1){ tester = strcmp(str1, ins); if (tester ==0){ // insert } tester = strcmp(str1, del); if (tester ==0){ // delete } tester = strcmp(str1, fde); if (tester ==0){ // force delete } tester = strcmp(str1, pst); if (tester ==0){ //print statistics } tester = strcmp(str1, prl); if (tester ==0){ // print list } tester = strcmp(str1, pcr); if (tester ==0){ // Print Count Range } tester = strcmp(str1, ppr); if (tester ==0){ // Print Prefix } tester = strcmp(str1, psu); if (tester ==0){ //Print Suffix } tester = strcmp(str1, end);
  • 6. if (tester ==0){ end1=1; exit(0); //end } else{ printf("unknown command "); end1=1; exit(0); } //accept next input here printf("Enter next command: "); scanf("%c %d", &str1, &secondarycommand); //accepts input as two strings, can parse to int later depending on the command } return 0; } Solution #include #include #include #define STRING_SIZE 11 /* Size of char array for the string */ #define COMMAND_SIZE 4 /* Size of char array for the command*/ #define PREFIX_SIZE 11 /* Size of char array for prefix */ #define SUFFIX_SIZE 11 /* Size of char array for suffix */ #define COMPARE_TO 3 /* Number of spots to compare command up until */ #define FIRST_COUNT 1
  • 7. /* Sets count to 1 */ #define SORT 1 /* Used to determine whether to sort list or not */ #define DONT_SORT 0 /* Used to determine whether to sort list or not */ #define LARGE_NUM 100000 /* Array size for int array for count in printStats */ #define ONE 1 /* Used in calculations */ /* Function Prototypes */ void insert(char[STRING_SIZE]); void createNewList(char[STRING_SIZE]); void delete(char[STRING_SIZE], int); void forcedDelete(int); void sortList(); int printStats(); void printList(); int printByCount(int, int); void printPrefix(char[PREFIX_SIZE]); void printSuffix(char[SUFFIX_SIZE]); /* Function Prototypes */ /* Explainations are within the function themselves */ typedef struct LinkedList /* Structrure definition for the linked list nodes */ { char symbol[STRING_SIZE]; /* String in node */ int count; /* Count of node */ struct LinkedList *next; } Node; /* Struct for nodes of the linked list */ Node *pHead = NULL; /* Pointer to head node */ Node *pTail = NULL; /* Pointer to tail node */ /* Pointers to the node */
  • 8. int main(void) /* Main function */ { char command[COMMAND_SIZE]; /* char array to store command */ char string[STRING_SIZE]; /* char array to store string */ char ins[] = "ins"; /* string command ins to commpare */ char del[] = "del"; /* string command del to commpare */ char fde[] = "fde"; /* string command fde to commpare */ char prl[] = "prl"; /* string command prl to commpare */ char end[] = "end"; /* string command end to commpare */ char pcr[] = "pcr"; /* string command pcr to commpare */ char pst[] = "pst"; /* string command pst to commpare */ char ppr[] = "ppr"; /* string command ppr to commpare */ char psu[] = "psu"; /* string command psu to commpare */ char pre[PREFIX_SIZE]; /* char array for user entered prefix */ char suf[SUFFIX_SIZE]; /* char array for user entered suffix */ int val; /* value to print range */ int val2; /* value to print range */ printf("Enter a command: "); fflush(stdout); scanf("%s", command);
  • 9. while (strcmp(command, end) != 0) /* Run while command doesn't equal "end" */ { if (strcmp(command, ins) == 0) /* Do this if user enters ins for insert */ { scanf("%s", string); /* input string */ insert(string); /* call insert function */ } else if (strcmp(command, del) == 0) /* Do this if user enters del */ { scanf("%s", string); /* input string */ delete(string, SORT); /* call delete function */ } else if (strcmp(command, fde) == 0) /* Do this if user enters fde */ { scanf("%d", &val); /* input int to force delete from */ forcedDelete(val); /* call forcedelete function */ } else if (strcmp(command, prl) == 0) /* Do this if user enters prl */ { printList(); /* call printList function */
  • 10. } else if (strcmp(command, pcr) == 0) /* Do this if user enters pcr */ { scanf("%d", &val); /* input int to print count from */ scanf("%d", &val2); /* input int to print count up until */ printByCount(val, val2); /* call printByCount function */ } else if (strcmp(command, pst) == 0) /* Do this if users enters pst */ { printStats(); /* Call printStats function */ } else if (strcmp(command, ppr) == 0) /* Do this if user enters ppr */ { scanf("%s", pre); /* input string into prefix variable */ printPrefix(pre); /* call printPrefix function */ } else if (strcmp(command, psu) == 0) /* Do this if user enters psu */ { scanf("%s", suf); /* input string into suffix variable */ printSuffix(suf); /* call printSuffix function */
  • 11. } printf(" Enter a command: "); fflush(stdout); scanf("%s", command); /* Prompt user to enter a command and * input command into string */ } if (strcmp(command, end) == 0) /* Do this if user inputs "end" */ { printf(" Program Closing "); fflush(stdout); } } void insert(char string[STRING_SIZE]) { Node *pNewNode = malloc(sizeof(Node)); Node *pLoop = pHead; if (pHead == NULL) { createNewList(string); /* Call create newList function */ } else { strcpy(pNewNode -> symbol, string); if (pHead == pTail) { if (strcmp(pHead -> symbol, pNewNode -> symbol) == 0) /* Do this if the second node being input equals head node */ { pHead -> count++;
  • 12. /* Increment head count by one */ } else { pNewNode -> count = FIRST_COUNT; pHead -> next = pNewNode; /* Have the head node point to the new node */ pTail = pNewNode; /* Insert the new node into tail */ pNewNode -> next = NULL; /* Remove the new from the list */ } } else { while (pLoop != NULL) /* run while node does not equal null */ { if (strcmp(pLoop -> symbol, pNewNode -> symbol) == 0) /* Do this if new node symbol equals current node symbol */ { pLoop -> count++; /* Increment current node count by one */ break; /* break out of loop */ } else if (pLoop -> next == NULL) /* Do this if next node equals null */ { pNewNode -> count = FIRST_COUNT; pTail -> next = pNewNode; /* Point the tail node to the new node */
  • 13. pNewNode -> next = NULL; /* Remove the new node frome the list */ pTail = pNewNode; /* Insert the new node into tail */ break; } pLoop = pLoop -> next; /* increment linked list */ } } sortList(); /* call sortList function */ } } void createNewList(char string[STRING_SIZE]) /* Function to create a new list */ { Node *pNewNode = malloc(sizeof(Node)); pNewNode -> next = NULL; strcpy(pNewNode -> symbol, string); /* Insert user's string into node */ pNewNode -> count = FIRST_COUNT; pHead = pTail = pNewNode; } void delete(char string[STRING_SIZE], int sort) /* Function to delete a node */ { Node *pCurr = pHead; Node *pPrev = NULL; if (pHead == NULL) { printf("This List Is Empty "); fflush(stdout);
  • 14. } while (pCurr != NULL) { if (strcmp(pCurr -> symbol, string) == 0) /* Do this if the current nodes symbol equals user inputed string */ { if (pCurr -> count > 1) /* If current node has a count greater than one*/ { pCurr -> count--; /* Decrement current node count by one */ } else { if (pCurr == pHead) { pHead = pCurr -> next; free(pCurr); /* * Free original head node from memory. */ } else { if ((pPrev == pHead) && (pCurr -> next == NULL)) { pTail = pHead; pHead -> next = NULL; } else if (pCurr -> next == NULL) /* If the next node equals null */ {
  • 15. pTail = pPrev; /* Make tail node the previous node */ pTail -> next = NULL; /* Have tail reference null */ free(pCurr); /* free current node from memory */ } else { pPrev -> next = pCurr -> next; free(pCurr); /* * Free removed node from memory. */ } } } } pPrev = pCurr; /* have the current node equal previous node */ pCurr = pCurr -> next; /* Increment current node */ } if (sort == 1) { sortList(); /* Call sortList function */ } } void printList() /* printList function */ { Node *pCurr = pHead;
  • 16. if (pHead == NULL) /* If head node equals null */ { printf("The list is empty. "); fflush(stdout); } else { printf(" Strings Entered: "); fflush(stdout); printf(" "); fflush(stdout); while (pCurr != NULL) /* run while current node isn't null */ { printf("%s", pCurr -> symbol); fflush(stdout); printf(" %d ", pCurr -> count); fflush(stdout); /* Print symbol and count from current node */ pCurr = pCurr -> next; /* Move to next node */ } } } void forcedDelete(int min) /* function to delete nodes based on count */ { Node *pCurr = pHead; int nodeCount; if (pHead == NULL) {
  • 17. printf("This List Is Empty "); fflush(stdout); } while(pCurr != NULL) /* run while current node isn't null */ { nodeCount = pCurr -> count; /* insert current nodes count into int variable */ if (nodeCount <= min) /* if nodeCount is less than min */ { while(nodeCount > 0) /* Run while nodeCount is greater than zero */ { nodeCount--; /* decrement nodeCount by one */ delete(pCurr -> symbol, DONT_SORT); /* Call delete function with current symbol and don't sort list */ } } pCurr = pCurr -> next; /* move to next node */ } } void sortList() /* Function to sort the list */ { Node *pCurr = pHead; Node *pNext = NULL; Node *pPrev = NULL; while (pCurr != NULL) /* Run while current node isn't null */ { pNext = pCurr -> next;
  • 18. /* set the next node */ if (pPrev == NULL) /* Check to see if it the head node */ { if (pNext == NULL); /* if next equals null, */ else if (pCurr -> count < pNext -> count) { if (pNext -> next == NULL) /* * If there are only 2 nodes in the linked list */ { pCurr -> next = pNext -> next; /* Set current reference to next reference */ pHead = pNext; /* Set next node equal to head */ pTail = pCurr; /* Set current equal to tail */ pHead -> next = pTail; /* have head node reference tail */ } else /* * If there are more than 2 nodes in the linked list */ { pCurr -> next = pNext -> next; /* Set current reference to next referenec */ pHead = pNext; /* Set next node equal to head */ pHead -> next = pCurr; /* have head equal current node */ sortList();
  • 19. /* call sortList again to continue sorting */ } } } else if (pNext == NULL) /* Do this if next node equals null */ { break; /* break out of loop */ } else if (pCurr -> count < pNext -> count) /* do this if current count is less than next count */ { if (pNext -> next == NULL) /* * If there are only 2 nodes in the linked list */ { pCurr -> next = pNext -> next; /* have current node reference the node next is pointing to */ pPrev -> next = pNext; /* have previous node reference the next node */ pTail = pCurr; /* insert current node into tail node */ pNext -> next = pCurr; /* have next node reference current node */ sortList(); /* call sortList function to continue sorting list */ } else { pPrev -> next = pNext;
  • 20. /* have previous node reference next node */ pCurr -> next = pNext -> next; /* have current node reference node the next node is referencing */ pNext -> next = pCurr; /* have next node reference the current node */ sortList(); /* call sortList function to continue sorting list */ } } pPrev = pCurr; /* have previous node equal current node */ pCurr = pCurr -> next; /* move to next node */ } } int printByCount(int v1, int v2) /* function to print out nodes between the range of the inputed count values */ { Node *pCurr; /* node pointer for current node */ int nodeCount; /* int variable for node count */ if(pHead == NULL) /* do this if head is null */ { printf("%s ","The list is empty"); fflush(stdout); return 0; /* leave function */ } pCurr = pHead; printf(" "); fflush(stdout); while(pCurr != NULL)
  • 21. /* loop through list while current doesn't equal null */ { nodeCount = pCurr -> count; /* insert current node count into nodeCount variables */ if(nodeCount >= v1 && nodeCount <= v2) { printf("%s",pCurr -> symbol); fflush(stdout); printf(" %d ", pCurr -> count); fflush(stdout); /* print node */ } pCurr = pCurr -> next; /* move to next node */ } return 0; } int printStats() /* function to print stats of nodes */ { Node *pCurr; /* pointer to current node */ int min = LARGE_NUM; /* minimum value */ int max = 0; /* max value */ double mean = 0; /* mean value */ int numCount = 0; /* count value */ int nodeCount; /* count value */ int numCount2; /* count value */
  • 22. int allCounts[LARGE_NUM]; /* array of all counts */ if(pHead == NULL) /* if list is empty */ { printf("%s ","The list is empty."); fflush(stdout); return 0; /* leave function */ } pCurr = pHead; /* insert head node into current */ while(pCurr != NULL) /* run while there are nodes in the linked list */ { nodeCount = pCurr -> count; /* set nodeCount to current count */ numCount++; /* increment numCount by one */ if(nodeCount > max) /* if nodeCount is greater than the max value */ { max = nodeCount; /* Set max value to current nodeCount */ } if(nodeCount < min) /* If nodeCount is less than the max value */ { min = nodeCount; /* Set min value to current nodeCount */ }
  • 23. allCounts[numCount - ONE] = nodeCount; /* Insert nodeCount into allCounts array at next available position */ pCurr = pCurr -> next; /* Set current node to next node */ } numCount2 = numCount; /* Insert numCount into numCount2 */ while(numCount2 > -ONE) /* run while numCount2 is greater than negative one */ { mean = mean + allCounts[numCount2 - ONE]; /* adds total count to mean to be calculated */ numCount2--; /* decrement numCount2 by one */ } mean = mean / numCount; /* Calculates mean */ printf(" "); fflush(stdout); printf("%s","The number of nodes in the list: "); fflush(stdout); printf("%d ",numCount); fflush(stdout); /* Prints the number of nodes in the list */ printf("%s","The maximum count in the list: "); fflush(stdout); printf("%d ",max); fflush(stdout); /* Prints the maximum count in the list */ printf("%s","The minimum count in the list: "); fflush(stdout); printf("%d ",min); fflush(stdout); /* prints the minimum count in the list */ printf("%s","The mean of the list's count values: "); fflush(stdout);
  • 24. printf("%f ",mean); fflush(stdout); /* prints the mean of all the counts in the list */ return 0; /* return to main function */ } void printPrefix(char pre[PREFIX_SIZE]) /* Function to print prefix */ { Node *pCurr = pHead; if (pHead == NULL) /* Run if the list is empty */ { printf("The List Is Empty "); fflush(stdout); } else { printf(" "); fflush(stdout); while (pCurr != NULL) { if (strstr(pCurr -> symbol, pre) != NULL) /* Runs if the prefix the user inputs is in the current node */ { if ((strcspn(pCurr -> symbol, pre) == 0) || (strncmp(pCurr -> symbol, pre, 3) == 0)) { printf("%s", pCurr -> symbol); fflush(stdout); printf(" %d ", pCurr -> count); fflush(stdout); /* Print string and count of string */ } } pCurr = pCurr -> next; /* move to next node */ } } }
  • 25. void printSuffix(char suf[SUFFIX_SIZE]) { int sufLen = 0; int symLen = 0; int index = 0; int nineNineK; /* integers used for string manipulations */ char endSym[LARGE_NUM]; Node *pCurr; /* pointer to a node; this is used to walk across the list */ if(pHead == NULL) /* prints "the list is empty if the first node in the list is NULL */ { printf("%s ", "The list is empty"); fflush(stdout); } else { pCurr = pHead; /* sets node to first node in list */ printf(" "); while(pCurr != NULL) /* loops while nodes remain */ { index = 0; nineNineK = LARGE_NUM - ONE; /* resetting variables used to keep track of positions in arrays */ while(nineNineK > - ONE) /* this loop sets every position of char array to '0' */ { endSym[nineNineK] = '0'; nineNineK = nineNineK - ONE;
  • 26. } symLen = (int)(strlen(pCurr -> symbol)); sufLen = (int)strlen(suf); /* gets length of symbol and passed string */ while(sufLen > 0) /* adds last n characters to new array to compare */ { endSym[index] = pCurr->symbol[symLen-sufLen]; sufLen = sufLen - 1; index = index + 1; } if(strstr(endSym, suf) != NULL) { printf("%s",pCurr-> symbol); fflush(stdout); printf(" %d ", pCurr-> count); fflush(stdout); } pCurr = pCurr-> next; /* moves to next node in list */ } } }