MCS – 011(PROBLEM SOLVING AND PROGRAMMING) (C LANGUAGE) Important Short Notes| Expected Question |IGNOU BCA|

The Indira Gandhi National Open University (IGNOU) offers MCS-011, “Problem Solving and Programming,” as a foundational subject for its Bachelor of Computer Applications (BCA) program. The goal of this course is to give students the fundamental knowledge and abilities needed to solve problems and write C programs. It acts as a thorough yet simple introduction to programming, offering a solid foundation for more complex computer science and software development courses.

program

Goals for MCS-011
The following are the main goals of MCS-011:

1. to teach students the principles of programming and how to solve problems.
2. to familiarize student with the C programming language’s syntax and semantics.
3. to become skilled at writing organized, effective, and thoroughly documented C programs.
4. to develop a knowledge of how to tackle and resolve challenging computational issues.
5. to prepare students for advanced classes in software engineering, data structures, and algorithms.

Introduction to MCS-011: Problem Solving and Programming

The Indira Gandhi National Open University (IGNOU) offers MCS-011, “Problem Solving and Programming,” as a required course for its Master of Computer Applications (MCA) program. The goal of this course is to give students a solid foundation in computational problem-solving and programming. Students will receive practical experience developing efficient and effective code, master fundamental programming principles, and build problem-solving skills using the C programming language.

MCS-011 is significant since it serves as a starting point for those interested in computer science. It prepares students for further advanced studies in the field by introducing them to the basic ideas and methods needed for software development. With an emphasis on C, a language known for its strength and adaptability, the course gives students abilities that are highly sought after in a variety of technological and industrial domains.

Understanding the Importance of MCS-011 Short Notes:

1. Overview : Brief notes reduce an extensive amount of material into essential ideas and points. They offer a rapid and effective means of studying the key subjects in advance of the examination.

2. Focus on the Essentials: You may focus on each topic’s key elements by summarizing the available information. This guarantees that you cover the most relevant subjects and helps in setting priorities for your study materials.

3. Improved Retention: Taking quick notes requires you to take an active role with the information. Compared to passive reading, active learning promotes improved understanding and retention of knowledge.

4. Quick Reference: Brief notes are a quick reference that come in helpful when making last-minute changes. To fast brush up on specific concepts or formulas, you can swiftly scan them.

5. Time management: You may cover a lot of ground in less time by taking brief notes. This is very helpful if you don’t have much time to study before the test.

Most Repeated MCS-011 Important Questions for IGNOU BCA Exams Semester Wise :

BLOCK-01

Ques. 1 Draw Flowchart with an Algorithms of each? The given number is Prime number or not?
,The given number is Factorial Number?

Answer:

Prime Number Algorithm and Flowchart

Algorithm:

  1. Start
  2. Input the number n
  3. If n <= 1, print “Not Prime” and go to step 8
  4. For i from 2 to sqrt(n):
    • If n % i == 0, print “Not Prime” and go to step 8
  5. Print “Prime”
  6. End

Flowchart:

Start | Input n | n <= 1 -- Yes --> Print "Not Prime" --> End | No |

For i = 2 to sqrt(n) | n % i == 0 -- Yes --> Print "Not Prime" --> End | No |

Print "Prime" | End

Factorial Number Algorithm and Flowchart

Algorithm:

  1. Start
  2. Input the number n
  3. Initialize factorial = 1
  4. For i from 1 to n:
    • Multiply factorial by i
  5. Print factorial
  6. End

Flowchart:

Start | Input n | factorial = 1 | For i = 1 to n | factorial = factorial * i | Print factorial | End


Ques. 2 Mention the rules of using Big-O notation ?
Answer:

  1. Worst-case Analysis: Big-O notation describes the upper bound performance of an algorithm, representing the worst-case scenario.
  2. Ignore Constants: Constant factors are not included in Big-O notation, e.g., O(2n) is simplified to O(n).
  3. Focus on Dominant Terms: Only the term with the highest growth rate is considered, e.g., O(n^2 + n) simplifies to O(n^2).
  4. Non-Negative: Big-O notation describes non-negative functions.
  5. Transitivity: If f(n) = O(g(n)) and g(n) = O(h(n)), then f(n) = O(h(n)).


Ques. 3 Explain the Linker errors ?

Answer:

Linker errors occur when a program is being compiled and the linker is unable to resolve all the references to functions or variables. These errors typically arise from:

  • Missing Definitions: Functions or variables declared but not defined.
  • Incorrect Function Signatures: Mismatches in the function declarations and definitions.
  • Multiple Definitions: Multiple definitions of the same function or variable.
  • Missing Libraries: Required libraries not included in the linking process.
  • Incorrect Paths: Paths to object files or libraries not specified correctly


Ques. 4 Explain variables? How are variables declared in C? What are the rules to name variables in C? How to assign a value to the variable at the time of declaration? Explain with a suitable example ?

Answer:

Variables are named storage locations in memory used to hold data that can be modified during program execution.

Declaration: Variables are declared with a type and a name. For example:

int age; float salary; char grade;

Rules for Naming Variables:

  1. Must begin with a letter or an underscore (_).
  2. Subsequent characters can be letters, digits, or underscores.
  3. Case-sensitive.
  4. Cannot be a reserved keyword.
  5. No special characters (other than underscore).

Assigning Values at Declaration: You can assign values during the declaration, for example:

int age = 25; float salary = 50000.0; char grade = 'A';

Example:

#include <stdio.h>

int main() {

int age = 25;

float salary = 50000.0;

char grade = 'A';

printf("Age: %d\n", age);

printf("Salary: %.2f\n", salary);

printf("Grade: %c\n", grade);

return 0;

}


Ques. 5 What are Arithmetical and Logical Operators ?

Answer:

Arithmetic Operators:

  • + : Addition
  • - : Subtraction
  • * : Multiplication
  • / : Division
  • % : Modulus (remainder)

Logical Operators:

  • && : Logical AND
  • || : Logical OR
  • ! : Logical NOT


Ques. 6 Difference between “&” and “&&” ?

Answer:

  • & (Bitwise AND): Performs a bitwise AND operation on each pair of corresponding bits of two operands.
  • int a = 5; // 0101 in binary
  • int b = 3; // 0011 in binary
  • int result = a & b; // 0001 in binary, which is 1

  • && (Logical AND): Evaluates to true if both operands are true; otherwise, it evaluates to false.
  • int a = 5;
  • int b = 3;
  • if (a > 1 && b < 5) {
  • // This block executes because both conditions are true
  • }

BLOCK 2

Ques. 1: Write the program to calculate the Factorial of a given input natural number.

Answer:

Here is a simple C program to calculate the factorial of a given natural number:

#include <stdio.h>

int main() {

int n, i;

unsigned long long factorial = 1;

printf("Enter a natural number: ");

scanf("%d", &n); // Check if the number is negative

if (n < 0) {

printf("Factorial of a negative number doesn't exist.\n");

} else {

for (i = 1; i <= n; ++i) {

factorial *= i;

}

printf("Factorial of %d = %llu\n", n, factorial); }

return 0;

}

Explanation of the following terms with examples in C:

a) If statement

The if statement is used to execute a block of code only if a specified condition is true.

Example:

#include <stdio.h>

int main() {

int number = 10;

if (number > 0) {

printf("The number is positive.\n");

}

return 0;

}

b) Nested if statement

A nested if statement is an if statement inside another if statement.

Example:

#include <stdio.h>

int main() {

int number = 10;

if (number > 0) {

if (number % 2 == 0) {

printf("The number is positive and even.\n");

} else {

printf("The number is positive but odd.\n");

}

}

return 0;

}

c) Switch statement

The switch statement allows a variable to be tested for equality against a list of values.

Example:

#include <stdio.h>

int main() {

int day = 4;

switch (day) {

case 1: printf("Monday\n");

break;

case 2: printf("Tuesday\n");

break;

case 3: printf("Wednesday\n");

break;

case 4: printf("Thursday\n");

break;

case 5: printf("Friday\n");

break;

case 6: printf("Saturday\n");

break;

case 7: printf("Sunday\n");

break;

default: printf("Invalid day\n");

}

return 0;

}

d) For loop statement

The for loop is used for repeating a block of code a known number of times.

Example:

#include <stdio.h>

int main() {

int i;

for (i = 1; i <= 5; ++i) {

printf("%d\n", i);

}

return 0;

}

e) While statement

The while loop is used to repeat a block of code as long as a specified condition is true.

Example:

#include <stdio.h>

int main() {

int i = 1;

while (i <= 5) {

printf("%d\n", i);

i++;

}

return 0;

}

f) Do while statement

The do while loop is similar to the while loop, but it tests the condition after executing the block of code.

Example:

#include <stdio.h>

int main() {

int i = 1;

do {

printf("%d\n", i);

i++;

}

while (i <= 5);

return 0;

}

g) Goto statement

The goto statement is used to transfer control to the labeled statement.

Example:

#include <stdio.h>

int main() {

int number = 10;

if (number > 0) {

goto positive;

}

positive: printf("The number is positive.\n");

return 0;

}

h) Break statement

The break statement is used to exit from a loop or a switch statement.

Example:

#include <stdio.h>

int main() {

int i;

for (i = 1; i <= 5; ++i) {

if (i == 3) {

break;

}

printf("%d\n", i);

}

return 0;

}

i) Continue statement

The continue statement is used to skip the rest of the code inside a loop for the current iteration and jump to the next iteration of the loop.

Example:

#include <stdio.h>

int main() {

int i;

for (i = 1; i <= 5; ++i) {

if (i == 3) {

continue;

}

printf("%d\n", i);

}

return 0;

}

Ques. 2: Write a program to find the string length without using strlen() function.

Answer:

Here is a simple C program to calculate the length of a string without using the strlen() function:

#include <stdio.h>

int main() {

char str[100];

int length = 0;

printf("Enter a string: ");

gets(str);

while (str[length] != '\0') {

length++;

}

printf("Length of the string is: %d\n", length);

return 0;

}

Ques. 3: Define the function prototypes with an example for each.

Answer:

A function prototype is a declaration of a function that specifies the function’s name, return type, and parameters (if any). It does not contain the body of the function.

Example:

#include <stdio.h> // Function prototype

int add(int, int);

int main() {

int a = 5, b = 10;

int result = add(a, b);

printf("Sum: %d\n", result);

return 0;

}

// Function definition

int add(int x, int y) {

return x + y;

}

In this example, int add(int, int); is the function prototype.

Ques. 4: Difference between Call by Reference and Call by Value using an example program for each.

Answer:

Call by Value:

In Call by Value, a copy of the actual parameter is passed to the function. Changes made to the parameter inside the function have no effect on the actual parameter.

Example:

#include <stdio.h>

void increment(int);

int main() {

int num = 10;

increment(num);

printf("Value after function call (Call by Value): %d\n", num);

return 0;

}

void increment(int n) {

n++;

}

Output:

Value after function call (Call by Value): 10

Call by Reference:

In Call by Reference, the address of the actual parameter is passed to the function. Changes made to the parameter inside the function affect the actual parameter.

Example:

#include <stdio.h>

void increment(int *);

int main() {

int num = 10;

increment(&num);

printf("Value after function call (Call by Reference): %d\n", num);

return 0;

}

void increment(int *n) {

(*n)++;

}

Output:

Value after function call (Call by Reference): 11

Ques. 5: What is Recursion? Write the recursion function in C to generate a Fibonacci Series.

Answer:

Recursion is a programming technique in which a function calls itself directly or indirectly. It is used to solve problems that can be divided into smaller, similar problems.

Example of a recursive function to generate the Fibonacci Series:

#include <stdio.h>

int fibonacci(int);

int main() {

int n, i;

printf("Enter the number of terms: ");

scanf("%d", &n);

printf("Fibonacci Series: ");

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

printf("%d ", fibonacci(i));

}

return 0;

}

int fibonacci(int n) {

if (n <= 1) {

return n;

}

return fibonacci(n - 1) + fibonacci(n - 2);

}

BLOCK-03

Ques. 1: Calculate the Net Salary if the basic TA, TD, allowance, and deduction are given using structures

To calculate the Net Salary using structures in C:

#include <stdio.h>

struct Salary {

float basic;

float TA;

float TD;

float allowance;

float deduction;

}

;

float calculateNetSalary(struct Salary s) {

return s.basic + s.TA + s.TD + s.allowance - s.deduction;

}

int main() {

struct Salary emp = {50000, 10000, 5000, 2000, 3000};

float netSalary = calculateNetSalary(emp);

printf("Net Salary: %.2f\n", netSalary);

return 0;

}

Ques. 2: Explain union. Give an example code segment to initialize a union and access a member of a union

A union is a special data type available in C that allows storing different data types in the same memory location.

#include <stdio.h>

#include <string.h>

union Data { int i; float f; char str[20];

};

int main() {

union Data data;

data.i = 10;

printf("data.i : %d\n", data.i);

data.f = 220.5;

printf("data.f : %.2f\n", data.f);

strcpy(data.str, "C Programming");

printf("data.str : %s\n", data.str);

return 0;

}

Ques. 3: Difference between Structure and Union

  • Structure: Each member has its own memory location. Members of a structure are accessed independently.
  • Union: All members share the same memory location. Only one member can be accessed at a time.

Ques. 4: Define a Pointer? How is a pointer variable different from an array? Illustrate the pointer concept with the help of a program in C?

A pointer is a variable that stores the memory address of another variable.

Difference between a Pointer and an Array:

  • Pointer: Stores the address of a variable.
  • Array: A collection of elements of the same type stored in contiguous memory locations.

#include <stdio.h>

void swapByValue(int a, int b) {

int temp = a;

a = b;

b = temp;

}

void swapByReference(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

}

int main() {

int x = 10, y = 20;

printf("Before swapByValue: x = %d, y = %d\n", x, y);

swapByValue(x, y);

printf("After swapByValue: x = %d, y = %d\n", x, y);

swapByReference(&x, &y);

printf("After swapByReference: x = %d, y = %d\n", x, y);

return 0;

}

Ques. 5: Write a program to swap the values

#include <stdio.h>

void swap(int *a, int *b) {

int temp = *a;

*a = *b;

*b = temp;

}

int main() {

int x = 10, y = 20;

printf("Before swap: x = %d, y = %d\n", x, y);

swap(&x, &y);

printf("After swap: x = %d, y = %d\n", x, y);

return 0;

}

Ques. 6: Write a program to reverse an input string using pointers?

#include <stdio.h>

void reverseString(char *str) {

char *start = str;

char *end = str;

char temp;

while (*end != '\0') {

end++;

}

end--;

while (start < end) {

temp = *start;

*start = *end;

*end = temp;

start++;

end--;

}

}

int main() {

char str[100];

printf("Enter a string: ");

gets(str); // Note: gets() is unsafe;

use fgets() in real applications reverseString(str);

printf("Reversed string: %s\n", str);

return 0;

}

Ques. 7: Write a program to test whether the given string is a number palindrome or not?

To test whether the given string is a number palindrome:

#include <stdio.h>

#include <string.h>

#include <ctype.h>

int isNumberPalindrome(char *str) {

int len = strlen(str);

for (int i = 0; i < len / 2; i++) {

if (!isdigit(str[i]) || str[i] != str[len - i - 1]) {

return 0;

}

}

return 1;

}

int main() {

char str[100];

printf("Enter a string: ");

gets(str);

if (isNumberPalindrome(str)) {

printf("The string is a number palindrome.\n");

}

else

{

printf("The string is not a number palindrome.\n");

}

return 0;

}

Ques. 8: Difference between Sequential and Random Access Files?

  • Sequential Access Files: Data is read or written in a specific, linear order, one record after the other. For example, reading a text file from start to finish.
  • Random Access Files: Data can be read or written in any order. This means you can jump directly to a specific location in the file to read or write data. This is useful for databases or any file that needs frequent updates.

Ques. 9: Define Macro. To find max among three given numbers using ifdef, #else?

#include <stdio.h>

#define MAX(a,b,c) ((a>b && a>c) ? a : (b>c ? b : c))

int main() {

int x = 10, y = 20, z = 15;

printf("Max: %d\n", MAX(x, y, z));

return 0;

}

Ques. 10: Write the program to find out the square and cube of a given number using macros?

#include <stdio.h>

#define SQUARE(x) ((x) * (x))

#define CUBE(x) ((x) * (x) * (x))

int main() {

int num = 3;

printf("Square of %d: %d\n", num, SQUARE(num));

printf("Cube of %d: %d\n", num, CUBE(num));

return 0;

}

Ques. 11: Explain the term File Handling? What is the use of fopen(), fclose() in file handling with an example in C?

File Handling in C refers to performing operations like creating, reading, writing, and closing files using file pointers and various functions. The fopen() function is used to open a file, and the fclose() function is used to close a file.

#include <stdio.h>

int main() {

FILE *fp;

fp = fopen("file.txt", "r");

if (fp == NULL) {

printf("Error opening file.\n");

return 1;

}

printf("File opened successfully.\n");

fclose(fp);

printf("File closed successfully.\n");

return 0;

}

Ques. 12: Write a program in C to copy the content from one file to another file?

#include <stdio.h>

int main() {

FILE *source, *target;

char ch;

source = fopen("source.txt", "r");

if (source == NULL) {

printf("Error opening source file.\n");

return 1;

}

target = fopen("target.txt", "w");

if (target == NULL) {

fclose(source);

printf("Error opening target file.\n");

return 1;

}

while ((ch = fgetc(source)) != EOF) {

fputc(ch, target);

}

fclose(source);

fclose(target);

printf("File copied successfully.\n");

return 0;

}

Ques. 13: Explain the use of the following functions in C with an example:

  • putc() and getc(): Used to write and read a character to/from a file.
  • fseek(): Sets the file position to a specified offset.
  • ftell(): Returns the current file position.
  • rewind(): Sets the file position to the beginning.
  • fwrite(): Writes data to a file.

#include <stdio.h>

int main() {

FILE *fp;

char ch;

fp = fopen("test.txt", "w+");

if (fp == NULL) {

printf("Error opening file.\n");

return 1;

}

putc('A', fp);

putc('B', fp);

rewind(fp); // Set position to the beginning

ch = getc(fp);

printf("First character: %c\n", ch);

ch = getc(fp);

printf("Second character: %c\n", ch);

fseek(fp, 0, SEEK_END); // Move to the end of the file

printf("File size: %ld bytes\n", ftell(fp));

fclose(fp);

return 0;

}

Some Important Topics

Ques 1. Write a program in C language to multiply two matrices A and B
of size 3*3?


Ques 2. Explain the following terms in C.
a) Local variable
b) Malloc()
c)calloc()
d)realloc()


Ques 3. Write the program in C to find the all number is Amstrong
numbers in the range of 0-999 ?


Ques 4. Find the largest and smallest number among three numbers given
as input? Also, draw a flowchart for these algorithms ?


Ques 5. Design an algorithm and draw a flowchart and program to
convert decimal number into binary number ?

Ques 6. Write a program to generate the following pattern?
a)
1
12
123
1234
12345
b)
C
CO
COB
COBA
COBAL
COBA
COB
CO
C
c)
1
222
33333
4444444
33333
222
1

Read More: ECO-02(ACCOUNTANCY) Important Short Notes| Expected Question |IGNOU BCA|

Download PDF Of Above Content In 3 Paper

Conclusion:

With these IGNOU MCS-011 BCA short notes, you’ll be well-equipped to tackle your exams with confidence. Remember to complement your study efforts with regular practice and mock tests. Good luck!

You May Also Like

More From Author

1 Comment

Add yours

+ Leave a Comment