Documente Academic
Documente Profesional
Documente Cultură
PIXELES CLASSES
MCA (IGNOU)
Course Code
Course Title
BCA &
: BCSL-045
Assignment Number
: BCA(IV)/L-045/Assignment/2015
www.pixelesindia.com
(5
Page | 2
PIXELES CLASSES
MCA (IGNOU)
BCA &
{
int a, b, c, i;
a = 0;
b = 1;
for(i=0;i<10;i++)
{
c=a+b;
a=b;
b=c;
printf(%d, c);
}
getch();
}
(4 marks)
char *s,*v,*p;
clrscr();
printf(enter the string)
gets(s);
v=p;
8750321695
do
, web: www.pixelesindia.com
{
*p=*s;
*p++;
*s++;
} while(*s!=NULL);
printf("\n the copied string is ::- %s",v);
getch();
}
www.pixelesindia.com
Page | 3
PIXELES CLASSES
MCA (IGNOU)
BCA &
(10 marks)
Ans:
#include<stdio.h>
void sort(int a[]) // used for sorting array
{
int i,j,t;
for(i=0;i<=4;i++)
{
for(j=i;j<=4;j++)
{
if(a[i]>=a[j])
{
t=a[i];
www.pixelesindia.com
Page | 4
PIXELES CLASSES
MCA (IGNOU)
a[i]=a[j];
a[j]=t;
}
}
}
}
void merge(int a[],int b[],int c[]) //this function passed three arguments
{
//as array first and second array will
int i=0,j=0,k=0;
//will be merged into third.
while(i<5 && j<5) //loop executes up to i or j becomes false
{
if(a[i]<b[j]) // if element of first array is less than second array,
{
// it will store into third array
c[k]=a[i];
i++;
}
else
{
c[k]=b[j];
//other wise element of second array
j++;
}
k++;
}
while(j<5) //j is less than 5 then all elements of second array go to third array
{
c[k]=b[j];
k++;
j++;
}
while(i<5) //i is less than 5 then all elements of first array go to third array
{
c[k]=a[i];
k++;
i++;
}
}
void disp(int c[],int size) // to display element of array
{
int i;
for(i=0;i<size;i++)
printf(" %d",c[i]);
}
main()
{
int a[]={5,8,2,7,10},b[]={1,4,12,9,11};
int c[10],j,k;
clrscr();
sort(a);
sort(b);
printf("\nMy first Array:");
disp(a,5);
www.pixelesindia.com
BCA &
Page | 5
PIXELES CLASSES
MCA (IGNOU)
BCA &
(10
Ans:
#include<stdio.h>
void selection(int arr[], int size)
{
int small,pos, temp,i,j,k;
for(i=0;i<size;i++)
{
small=arr[i];
for(j=i;j<size;j++)
{
if(arr[j]<=small)
{
small=arr[j];
pos=j;
}
}
temp=arr[i];
arr[i]=arr[pos];
arr[pos]=temp;
}
}
void disp(int arr[], int size)
{
int i;
clrscr();
for(i=0;i<size;i++)
printf("%d\t",arr[i]);
}
Regular Classes
BCA & MCA IGNOU Special Institute
Free Trial Classes
Subjective Knowledge
Free PIXELES Guide Books (Prepared by our
teachers)
Free Solved Assignments
Experienced Faculties
100% Results
Home Test Series
Class Test Series
We teach you until you pass
Final Year Synopsis & Project
Proper Guidance
void main()
{
int arr[]={5,13,18,19,2,7,4,12,1,6};
clrscr();
selection(arr,10);
disp(arr,10);
getch();
}
www.pixelesindia.com