CAN ANYONE DRAW ME A FLOWCHART FOR THIS CODE. #include #include #include struct studentn

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

CAN ANYONE DRAW ME A FLOWCHART FOR THIS CODE. #include #include #include struct studentn

Post by answerhappygod »

CAN ANYONE DRAW ME A FLOWCHART FOR THIS
CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct studentname {
char letter[1];
struct studentname *next;
};

typedef struct studentname STUDENTName;
typedef STUDENTName *STUDENTNamePtr;
void printlist(STUDENTNamePtr startptr) //print
fucntion
{
STUDENTNamePtr crntptr;
crntptr=startptr;
printf("Print my last name in alphabetical
order\n");
while(crntptr!=NULL)
{
printf(" %s
->",crntptr->letter);

crntptr=crntptr->next;
}
printf("NULL");
}
int main()
{
// creating pointer pointer for node
STUDENTNamePtr startptr=NULL;
STUDENTNamePtr newptr;
STUDENTNamePtr crntptr;

// Create a linked list manually base on my last
name: NEFAT

newptr=(STUDENTName*)malloc(sizeof(STUDENTName));
strcpy(newptr->letter,"n");
newptr->next=NULL;
startptr=newptr;//assign startptr to
newptr


newptr=(STUDENTName*)malloc(sizeof(STUDENTName));
strcpy(newptr->letter,"e");
newptr->next=NULL;
startptr->next=newptr; //connect the first
node to newptr node
crntptr=newptr; // assign current pointer to
this node


newptr=(STUDENTName*)malloc(sizeof(STUDENTName));
strcpy(newptr->letter,"f");
newptr->next=NULL;
crntptr->next=newptr; //connect the last node
to newptr node
crntptr=newptr; // assign current pointer to
this node


newptr=(STUDENTName*)malloc(sizeof(STUDENTName));
strcpy(newptr->letter,"a");
newptr->next=NULL;
crntptr->next=newptr; //connect the last node
to newptr node
crntptr=newptr; // assign current pointer to
this node


newptr=(STUDENTName*)malloc(sizeof(STUDENTName));
strcpy(newptr->letter,"t");
newptr->next=NULL;
crntptr->next=newptr; //connect the last node
to newptr node
crntptr=newptr; // assign current pointer to
this node

printlist(startptr); //using the print
function

}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply