Professional Documents
Culture Documents
MCS 011 Solved Assignments 2016
MCS 011 Solved Assignments 2016
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
2. Compare and contrast the characteristics and/or organisation of the Write an
interactive C program for Q1.(10 Marks)
Ans:-
#include<stdio.h> Page | 2
#include<conio.h>
main()
{
char qs[][100]={
{"\n1. PIXELES Classes teach...Students.\n\t (1). IGNOU (2). IP"},
{"\n2. Who is CM of Delhi? \n\t(1). Narender Modi (2). Arvind Kej"},
{"\n3. What colour is Grass? \n\t(1). Green (2). Black"},
{"\n4. PIXELES Classes are Located at....\n\t(1). Nangloi & Uttam
Nagar (2). Narela & Nangloi"},
{"\n5. Duration of BCA is....\n\t(1). 8 Years (2). 3 Years"},
};
int ans[]={1,2,1,1,2};
int choice;
int score=0,a=0,t;
for(a=0;a<5;a++)
{
clrscr();
puts(qs[a]);
printf("\nEnter the Ans( 1 or 2 )....\n");
scanf("%d",&choice);
if(ans[a]==choice)
score=score+1;
if(a<4)
{
printf("\nPress enter for select Next Question...\n");
getch();
}
else
printf("\nGame Over\n");
}
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
printf("\nyour score is=%d",score);
getch();
}
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
c = a >> 2;
printf("Value of c is %d\n", c );
}
4. Define an array. Write an interactive C program to take two single dimensional
arrays of integers and merge them into a single dimensional array, excluding the Page | 4
common elements of both the arrays.
(10 Marks)
Ans:
“An array is collection of data having same data type that can be accessed by a numerical
index and represented by same name”.
int num [5];
Here ‘num’ is a variable name that can accept 5 integer value. Data are stored in array are
called elements of array and [ ] is called subscript. Memory representation of array- it
allocates 10 bytes memory space for the 5-integer value. It allocates contiguous memory
location.
#include<stdio.h>
void sort(int a[])
{
int i,j,t;
for(i=0;i<=4;i++)
{
for(j=i;j<=4;j++)
{
if(a[i]>=a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
int merge(int a[],int b[],int c[])
{
int i=0,j=0,k=0;
while(i<5 && j<5)
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
{
if(a[i]<b[j])
{
c[k]=a[i];
i++; Page | 5
k++;
}
else if (a[i]==b[j])
{
c[k]=b[j];
i++;
j++;
k++;
}
else
{
c[k]=b[j]; Branches & Contacts Details
j++;
k++; Uttam Nagar:-WZ-B7, Old Pankha Nangloi:-Plot. No-19, Ext- 2A,
oppBanke-Bihari, Talabwali Road,
} Road (Opp. Primary School), Near
Nangloi, Delhi-41
East Metro Station, Uttam Nagar,
}
New Delhi-59
while(j<5)
{
c[k]=b[j]; Ph: 9213327975, 9716339580
k++;
8750321695
j++;
pixeles@rediffmail.com,
www.pixelesindia.com
}
while(i<5)
{
c[k]=a[i];
k++;
i++;
}
return k;
}
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
void disp(int c[],int size) // to display element of array
{
int i;
for(i=0;i<size;i++)
printf(" %d",c[i]); Page | 6
}
main()
We are teaching IGNOU’s BCA & MCA Students
{
int a[5],b[5]; Why join us?
int c[10],i,j,k,s;
Regular Classes
clrscr();
printf("enter the array first\n"); BCA & MCA IGNOU Special Institute
for(i=0;i<5;i++) Free Trial Classes
{
scanf("%d",&a[i]); Subjective Knowledge
s=merge(a,b,c);
printf("\n\nMerged Array:%d\n",s);
disp(c,s);
getch();
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
}
5. Write an interactive C program which illustrates the following concepts:
(i) Function with no arguments and no return value.
(ii) Function with arguments and no return value.
(iii) Function with arguments and with return value. Page | 7
(10 Marks)
Ans:-
#include<stdio.h>
void sum() //Function with no arguments and no return value.
{
int a,b,c;
printf("enter the number");
scanf("%d%d",&a,&b);
c=a+b;
printf("\nSum=%d",c);
}
void add(int a, int b) //Function with arguments and no return value.
{
int c;
c=a+b;
printf("\nadd=%d",c);
}
int calculate(int a, int b) //Function with arguments and return value.
{
int c;
c=a+b;
return c;
}
main()
{
int x;
clrscr();
sum();
add(4,5);
x=calculate(7,5);
printf("\ncalculate=%d",x);
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
getch();
};
6. Write an interactive C program to manage the assignments at study centres for the
first semester courses of MCA (MCS-011, 012, 13, 014, 015, MCSL-016 and MCSL-
017). Maximum marks for each assignment is 100 marks and weightage is 25%. Page | 8
Attending the viva-voce at the study centre for each assignment is compulsory. Pass
percentage in each assignment is 40%.
(Note: Use Structures concept).
Ans:
#include<stdio.h>
struct std
{
int enrol;
char Name[15];
int m1,m2,m3,m4,m5,m6,m7;
}s;
FILE *f1,*f2;
void input()
{
f1=fopen("data1","ab");
printf("\nEnter the Enrol\n");
scanf("%d",&s.enrol);
printf("\n MCS-011:Marks obtain out of100 is:");
scanf("%d",&s.m1);
printf("\n Enter MCS-012:Marks obtain out of100 is:");
scanf("%d",&s.m2);
printf("\n Enter MCS-013:Marks obtain out of100 is:");
scanf("%d",&s.m3);
printf("\n Enter MCS-014:Marks obtain out of100 is:");
scanf("%d",&s.m4);
printf("\n Enter MCS-015:Marks obtain out of100 is:");
scanf("%d",&s.m5);
printf("\n Enter MCSL-016:Marks obtain out of100 is:");
scanf("%d",&s.m6);
printf("\n Enter MCSL-017:Marks obtain out of100 is:");
scanf("%d",&s.m7);
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
fwrite(&s,sizeof(s),1,f1);
fflush(stdin);
fclose(f1);
} Page | 9
void output()
{
f1=fopen("data1","r+b");
fflush(f1);
rewind(f1);
while(fread(&s,sizeof(s),1,f1))
{
printf("Enrol : %d\n",s.enrol);
printf("MCS-011 : %d\n",s.m1);
printf("MCS-012 : %d\n",s.m2);
printf("MCS-013 : %d\n",s.m3);
printf("MCS-014 : %d\n",s.m4);
printf("MCS-015 : %d\n",s.m5);
printf("MCSL-016: %d\n",s.m6);
printf("MCSL-017: %d\n",s.m7);
}
close(f1);
}
main()
{
int ch;
char cc;
do
{
clrscr();
printf("\n1-for Add");
printf("\n2-for Display");
printf("\n3-for exit");
printf ("\nEnter your choice");
scanf("%d",&ch);
www.pixelesindia.com
PIXELES CLASSES BCA & MCA (IGNOU)
switch(ch)
{ Disclaimer: Institution and publisher are neither responsible
case 1: for the result of the any action taken on the basis of this work
or any omissions or errors.
input();
break; Page | 10
case 2:
output();
break;
case 3:
break;
}
printf("\nDo you want to Continue(Y/N)\n");
cc=getche();
}while(cc=='y'|| cc=='Y');
getch();
}
www.pixelesindia.com