Data Structures and Algorithms: C Programming Exercises, Exams of Data Structures and Algorithms

It is one type of data structure. we are using this concept in c language.

Typology: Exams

2017/2018

Uploaded on 10/20/2018

music-world-1
music-world-1 🇮🇳

4 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DATA STRUCTURE
ASSIGNMENT
NAME:R.SURESH
REG.NO:BU170509
SUBJECT:B.SC.CS
SUBMITTEDBY:
M.SERLINRAJ(proessor)
1. Develop a C program for following out using
singly linked list.
Enter a Number:24
Want to Continue[y/n]: y
pf3
pf4

Partial preview of the text

Download Data Structures and Algorithms: C Programming Exercises and more Exams Data Structures and Algorithms in PDF only on Docsity!

DATA STRUCTURE

ASSIGNMENT

NAME:R.SURESH

REG.NO:BU

SUBJECT:B.SC.CS

SUBMITTEDBY:

M.SERLINRAJ(proffessor)

1. Develop a C program for following out using

singly linked list.

Enter a Number:

Want to Continue[y/n]: y

Enter a Number: 34

Want to Continue[y/n]: y

Enter a Number: 44

Want to Continue[y/n]: n

The Values of the Linked list are:

24 34 44

PROGRAM:

#include<stdio.h>

struct node

int number;

struct node *p;

}h,f,*t;

main()

char c;

f=NULL;

do

h=(struct node*)malloc(sizeof(struct node));

printf(“\n enter the number”);

scanf(“%d”,&h->number);

if(f!=NULL)

t->p=h;

t=h;

else f=t=h;

fflush(stdin);

printf(“\n Continue (Y/N):”);

scanf(“%c”,&c);

while(c==’Y’)

t->p=NULL;

t=f;

printf(“\n the list elements are: ”);

while(t!=NULL)

printf(“%d”,t->number);

t=t->p;

float f=0,i; for(i=0;i<n;i++) { f=f+(p); p++; } return (f/n); } void main() { int a[10],i,p; float avg; printf("Enter the no. of Subject: "); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter the Subject-%d Marks= ",i+1); scanf("%d",&a[i]); } p=a; avg=average(p); printf("the average marks = %f",avg); }