tutors name is prince and my name is tauseef. PAVE TP 1 2017 uigity of Technolog
ID: 3867091 • Letter: T
Question
tutors name is prince and my name is tauseef.
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
struct friend {
char name[20];
struct friend *next;
};
typedef struct friend FRIEND;
typedef FRIEND * FRIENDPtr;
int main(){
FRIENDPtr startptr,ptr,ptr1;
startptr = (FRIENDPtr)malloc(sizeof(FRIEND));
startptr->name[0] ='P';
startptr->name[1] ='e';
startptr->name[2] ='t';
startptr->name[3] ='e';
startptr->name[4] ='r';
startptr->next = (FRIENDPtr)malloc(sizeof(FRIEND));
ptr = startptr->next;
ptr->name[0] = 'Z';
ptr->name[1] = 'e';
ptr->name[2] = 'n';
ptr->next = NULL;
ptr1 = ptr;
ptr = startptr;
ptr->next = (FRIENDPtr)malloc(sizeof(FRIEND));
ptr = ptr->next;
ptr->name[0] ='P';
ptr->name[1] ='r';
ptr->name[2] ='i';
ptr->name[3] ='n';
ptr->name[4] ='c';
ptr->name[5] ='e';
ptr->next = (FRIENDPtr)malloc(sizeof(FRIEND));
ptr = ptr->next;
ptr->name[0] ='T';
ptr->name[1] ='a';
ptr->name[2] ='u';
ptr->name[3] ='s';
ptr->name[4] ='e';
ptr->name[5] ='e';
ptr->name[6] ='f';
ptr->next = ptr1;
ptr = startptr;
while (ptr != NULL){
printf("%s ",ptr->name);
ptr = ptr->next;
}
printf(" ");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.