MCS-011 Solved Assignment 2015-16 Ip

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Ignousolvedassignments.

com
Course Code : MCS-011
Course Title : Problem Solving and Programming
Assignment Number : MCA(I)/011/Assignment/15-16
Maximum Marks : 100
Weightage : 25%

Last Dates for Submission : 15th October, 2015 (For July 2015 Session)
15th April, 2016 (For January 2016 Session)

1. Define a flowchart. Write an algorithm and draw a corresponding flowchart to create a simple
multiple choice question (MCQ) examination of 25 questions for 50 marks along with evaluation
process too. (20 Marks)
Ans : A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This diagrammatic
representation illustrates a solution model to a given problem. Flowcharts are used in analyzing,
designing, documenting or managing a process or program in various fields.
Flowcharts are used in designing and documenting simple processes or programs. Like other types of
diagrams, they help visualize what is going on and thereby help understand a process, and perhaps also
find flaws, bottlenecks, and other less-obvious features within it. There are many different types of
flowcharts, and each type has its own repertoire of boxes and notational conventions. The two most
common types of boxes in a flowchart are:

a processing step, usually called activity, and denoted as a rectangular box

a decision, usually denoted as a diamond.

A flowchart is described as "cross-functional" when the page is divided into


different swimlanes describing the control of different organizational units. A symbol appearing in a
particular "lane" is within the control of that organizational unit. This technique allows the author to locate
the responsibility for performing an action or making a decision correctly, showing the responsibility of
each organizational unit for different parts of a single process.
Flowcharts depict certain aspects of processes and they are usually complemented by other types of
diagram. For instance, Kaoru Ishikawa defined the flowchart as one of the seven basic tools of quality
control, next to the histogram, Pareto chart, check sheet, control chart, cause-and-effect diagram, and
the scatter diagram. Similarly, in UML, a standard concept-modeling notation used in software
development, the activity diagram, which is a type of flowchart, is just one of many different diagram
types.

Thanks for visiting us!! Subscribe !!

Page 1

Ignousolvedassignments.com
Nassi-Shneiderman diagrams and Drakon-charts are an alternative notation for process flow.
Common alternative names include: flowchart, process flowchart, functional flowchart, process map,
process chart, functional process chart, business process model, process model, process flow
diagram, work flow diagram, business flow diagram. The terms "flowchart" and "flow chart" are used
interchangeably.
The underlying graph structure of a flow chart is a flow graph, which abstracts away node types, their
contents and other ancillary information.

Flowchart to create a simple multiple choice question (MCQ) examination

2. Compare and contrast the characteristics and/or organisation of the Write an interactive C
program for Q1. (10 Marks)
#include<stdio.h>
#include<conio.h>
main()
Thanks for visiting us!! Subscribe !!

Page 2

Ignousolvedassignments.com
{
char qs[][100]= {
{\n 1. In which state you stay at \n\t (1). Delhi (2). Outside Delhi},
{\n 2. Who is the CM of Delhi ? \n\t (1). Sheila Dixit (2). Arvind Kejriwal},
{\n 3. Grass is of which colour ? \n\t (1). Green (2). Black },
{\n 4. Duration of MCA is \n\t (1) 5years (2) 3Years},
{\n 5. IGNOU Head office is situated where in delhi},
};
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(\n Enter the Answer (1 0r 2) \t\t\n);
scanf(%d, &choice);
if(ans[a]==choice)
score= score+1
if(a<4)
{
printf(\n Press enter to select next question...\n);
getch();
}
else
printf(\n The End \n);
}
printf(\n your total score is = %d, score);
getch();
}

3. Discuss the significance of BITWISE operators in C programming language. Also, write an


interactive C program to illustrate them. (10 Marks)
The Bitwise operators supported by C language are listed in the following table. Assume variable A
holds 60 and variable B holds 13, then:
Description

Example

&

Binary AND Operator copies a bit to the result if it exists


in both operands.

(A & B) will give 12 which is


0000 1100

Binary OR Operator copies a bit if it exists in either


operand.

(A | B) will give 61 which is


0011 1101

Binary XOR Operator copies the bit if it is set in one

(A ^ B) will give 49 which is

Operator

Thanks for visiting us!! Subscribe !!

Page 3

Ignousolvedassignments.com
operand but not both.

0011 0001

Binary Ones Complement Operator is unary and has the


effect of 'flipping' bits.

(~A ) will give -61 which is 1100


0011 in 2's complement form
due to a signed binary number.

<<

Binary Left Shift Operator. The left operands value is


moved left by the number of bits specified by the right
operand.

A << 2 will give 240 which is


1111 0000

>>

Binary Right Shift Operator. The left operands value is


moved right by the number of bits specified by the right
operand.

A >> 2 will give 15 which is


0000 1111

Example
Try the following example to understand all the bitwise operators available in C programming
language:
#include <stdio.h>
main()
{
unsigned int a = 60;
unsigned int b = 13;
int c = 0;
c = a & b;
printf("Q1 - Value of c is %d\n", c );
c = a | b;
printf( Q2 - Value of c is %d\n", c );
c = a ^ b;
printf("Q3 - Value of c is %d\n", c );
Thanks for visiting us!! Subscribe !!

Page 4

Ignousolvedassignments.com
c = ~a;
printf("Q4 - Value of c is %d\n", c );
c = a << 2;
printf("Q5 - Value of c is %d\n", c );
c = a >> 2;
printf("Q6 - Value of c is %d\n", c );
}
When you compile and execute the above program it produces the following result:
Q1 - Value of c is 12
Q2 - Value of c is 61
Q3 - Value of c is 49
Q4 - Value of c is -61
Q5 - Value of c is 240
Q6 - Value of c is 15

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 common elements of both
the arrays. (10 Marks)
C programming language provides a data structure called the array, which can store a fixed-size
sequential collection of elements of the same type. An array is used to store a collection of data, but it is
often more useful to think of an array as a collection of variables of the same type.
Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare
one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent
individual variables. A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element
and the highest address to the last element.

Thanks for visiting us!! Subscribe !!

Page 5

Ignousolvedassignments.com

#include <stdio.h>
void merge(int [], int, int [], int, int []);
int main() {
int a[100], b[100], m, n, c, sorted[200];
printf("Input number of elements in first array\n");
scanf("%d", &m);

printf("Input %d integers\n", m);


for (c = 0; c < m; c++)
}

scanf("%d", &a[c]);

printf("Input number of elements in second array\n");


scanf("%d", &n);

printf("Input %d integers\n", n);


for (c = 0; c < n; c++)
}

scanf("%d", &b[c]);

merge(a, m, b, n, sorted);
printf("Sorted array:\n");
{

for (c = 0; c < m + n; c++)


}

printf("%d\n", sorted[c]);

return 0;

void merge(int a[], int m, int b[], int n, int sorted[]) {


int i, j, k;

Thanks for visiting us!! Subscribe !!

Page 6

Ignousolvedassignments.com
j = k = 0;
{

for (i = 0; i < m + n;)


if (j < m && k < n)

if (a[j] < b[k])

sorted[i] = a[j];
j++;

}
Else

sorted[i] = b[k];
k++;

}
i++;

}
else if (j == m) {
for (; i < m + n;)

}
else {
for (; i < m + n;)

sorted[i] = b[k];
k++;
i++;

sorted[i] = a[j];
j++;
i++;

5. Write an interactive C program which illustrates the following concepts:


(i) Function with no arguments and no return value.
#include<stdio.h>
void area();
void main()
{
Thanks for visiting us!! Subscribe !!

Page 7

Ignousolvedassignments.com
area();
}
void area()
{
float area_circle;
float rad;
printf("\nEnter the radius : ");
scanf("%f",&rad);
area_circle = 3.14 * rad * rad ;
}

printf("Area of Circle = %f",area_circle);

Output :
Enter the radius : 3
Area of Circle = 28.260000

(ii) Function with arguments and no return value.


#include<stdio.h>
#include<conio.h>
//---------------------------------------void area(float rad);

// Prototype Declaration

//---------------------------------------void main()
{
float rad;
printf("nEnter the radius : ");
scanf("%f",&rad);
area(rad);
getch();
}
//---------------------------------------void area(float rad)
{
float ar;
ar = 3.14 * rad * rad ;

Thanks for visiting us!! Subscribe !!

Page 8

Ignousolvedassignments.com
printf("Area of Circle = %f",ar);
}

Output :
Enter the radius : 3
Area of Circle = 28.260000

(iii) Function with arguments and with return value. (10 Marks)
#include<stdio.h>
float calculate_area(int);
int main()
{
int radius;
float area;
printf("\n Enter the radius of the circle : ");
scanf("%d",&radius);
area = calculate_area(radius);
printf("\nArea of Circle : %f ",area);
return(0);
}
float calculate_area(int radius)
{
float areaOfCircle;
areaOfCircle = 3.14 * radius * radius;
return(areaOfCircle);
}
Output :
Enter the radius of the circle : 2
Area of Circle : 12.56

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%. Attending the viva-voce at the
study centre for each assignment is compulsory. Pass percentage in each assignment is 40%.
(Note: Use Structures concept).
Answer:

Thanks for visiting us!! Subscribe !!

Page 9

Ignousolvedassignments.com

Thanks for visiting us!! Subscribe !!

Page 10

Ignousolvedassignments.com

Thanks for visiting us!! Subscribe !!

Page 11

Ignousolvedassignments.com

Thanks for visiting us!! Subscribe !!

Page 12

You might also like