0% found this document useful (0 votes)
24 views3 pages

Source Code

souce cor dof program

Uploaded by

Rohit Khatri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Source Code

souce cor dof program

Uploaded by

Rohit Khatri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

SOURCE CODE:

/*
Name
Roll No.
Batch
Semester
Date of submission
Faculty in-charge
*/

Rohit Khatri
CSE/14/320
2014
4th Semester
19 April,2016
Mr Abhishek Sharma

//Bridge Course Program No. > 10


// main.c
#include<stdio.h>
#include<stdlib.h>
#include "header.h"
struct sublist
{
int no_of_element;
int subaar[100];
}a[100],b[100];
int size,i,j,k,l;
int main()
{
int choice,a;
printf("\n");
printf("***MENU***\n");
printf("1. Create List\n");
printf("2. Reverse List\n");
printf("3. Display List\n");
printf("4. Exit\n");
printf("Enter your choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
create();
}
break;
case 2:
{
reverse();
}
break;
case 3:
{
display();
}
break;
case 4:
{
exit(0);
}
break;
default:

//Array of Structure

{
printf("Invalid Input\n");
}
break;
}
printf("\nPress '1' to continue....\n");
scanf("%d",&a);
if(a==1)
{
main();
}
else
{
exit(0);
}
return 0;
}
// header.h
extern void create();
extern void reverse();
extern void display();
//function.c
int i,j,k,l,size;
struct sublist
{
int no_of_element;
int subaar[100];
}a[100],b[100];
void create()
//create function
{
printf("Enter the size of array : "); // size of outer array
scanf("%d",&size);
for(i=0;i<size;i++)
// for insert element in a.subaar
{
printf("\n");
printf("Enter the size of %d inner array : ",i+1);
//size of
inner array
scanf("%d",&a[i].no_of_element);
printf("\n");
printf("Enter element in %d inner array\n",i+1);
for(j=0;j<a[i].no_of_element;j++)
{
scanf("%d",&a[i].subaar[j]);
}
printf("\n");
}
printf("\nEnter Elements are : ");
printf("\n\n");
printf("[ ");
for(i=0;i<size;i++)// for printing a.subarr
{
printf(" [");
for(j=0;j<a[i].no_of_element;j++)

{
printf(" %d ",a[i].subaar[j]);
}
printf("] ");
}
printf("]\n");
}
void reverse()
//reverse function
{
for(i=(size-1),k=0;i>=0;i--,k++) // for copy a.subarr in b.subarr
{
b[k].no_of_element= a[i].no_of_element;
for(j=(a[i].no_of_element-1),l=0;j>=0; j--,l++)
{
b[k].subaar[l] =a[i].subaar[j];
}
}
}
void display()
//display function
{
printf("\n");
printf("Element list Before reverse : ");
printf("\n[ ");
for(i=0;i<size;i++)// for printing a.subarr
{
printf(" [");
for(j=0;j<a[i].no_of_element;j++)
{
printf(" %d ",a[i].subaar[j]);
}
printf("] ");
}
printf(" ]");
printf("\n");
printf("\nElement list after reverse : ");
printf("\n");
printf(" [");
for(i=0;i<size;i++)// for printing b.subarr
{
printf(" [");
for(j=0;j<b[i].no_of_element;j++)
{
printf(" %d ",b[i].subaar[j]);
}
printf("] ");
}
printf(" ]");
printf("\n");
return 0;
}

You might also like