Knowlet

MATHEMATICS: Mathematical Programming in C | FYUG 2025


UNIT-I: C Fundamentals

Question 1 (a)

1 Mark

Question: Write the syntax for variable declaration in C.

Solution:

data_type variable_name;

Example: int count; or float price;

Question 1 (b)

1 Mark

Question: Write the syntax to define a symbolic constant.

Solution:

#define CONSTANT_NAME value

Example: #define PI 3.14159

Question 1 (c)

1 Mark

Question: How will you write the arithmetic expression a² + 10a - 8 in C?

Solution:

a * a + 10 * a - 8;

Alternatively, using the math library: pow(a, 2) + 10 * a - 8;

Question 1 (d)

1 Mark

Question: How will you assign the value 100 to the variable x at the time of variable declaration?

Solution:

int x = 100;

Question 2 (a)

2 Marks

Question: Which of the following are valid variable names: Char, First_name, List one, 2int_type?

Solution:

  • Char: Valid (C is case-sensitive; char is a keyword, but Char is not).
  • First_name: Valid (contains letters and underscores).
  • List one: Invalid (contains a space).
  • 2int_type: Invalid (cannot start with a digit).

Question 3 (a)

5 Marks

Question: Write the rules for naming identifiers.

Solution:

  1. An identifier can only contain alphabets (uppercase and lowercase), digits, and underscores (_).
  2. The first character must be an alphabet or an underscore. It cannot be a digit.
  3. Keywords (like int, while, etc.) cannot be used as identifiers.
  4. Identifiers are case-sensitive (e.g., Total and total are different).
  5. No special characters or spaces are allowed except for the underscore.

UNIT-II: Operators and Control Flow

Question 4 (a)

1 Mark

Question: What are the relational operators in C?

Solution:

Relational operators are used to compare two values. They are:

  • == (Equal to)
  • != (Not equal to)
  • > (Greater than)
  • < (Less than)
  • >= (Greater than or equal to)
  • <= (Less than or equal to)

Question 5 (a)

2 Marks

Question: What is the error in: int x=10; float y=4.25; x=y%x;?

Solution:

The error lies in the expression x = y % x;.

Error: The modulo operator (%) can only be used with integer operands. Since y is a float, this operation is illegal in C.

Question 6 (a)

5 Marks

Question: Write a C program to read two integers m and n and to decide and print whether m is a multiple of n.

Solution:

 #include  int main() { int m, n; printf("Enter two integers (m and n): "); scanf("%d %d", &m, &n); if (n != 0 && m % n == 0) { printf("%d is a multiple of %d\n", m, n); } else { printf("%d is not a multiple of %d\n", m, n); } return 0; } 

UNIT-III: Loops and Logic

Question 7 (a)

1 Mark [span_30](start_span)

Question: Write the general syntax of for loop.[span_30](end_span)

Solution:

 for (initialization; condition; increment/decrement) { // Statements to be executed } 

Question 9 (a)

5 Marks [span_32](start_span)

Question: Write the rules for switch statement.[span_32](end_span)

Solution:

  1. The switch expression must be an integral type (int or char).
  2. Each case label must be a unique constant expression.
  3. The break statement is optional but used to exit the switch block; otherwise, execution "falls through" to the next case.
  4. The default case is optional and executes if no case matches.
  5. Case labels must end with a colon (:).

UNIT-IV: Functions and Recursion

Question 10 (a)

1 Mark [span_39](start_span)

Question: Every program must have a ______ function.[span_39](end_span)

Solution:

main

Question 11 (b)

2 Marks [span_41](start_span)

Question: What is recursion?[span_41](end_span)

Solution:

Recursion is a programming technique where a function calls itself, either directly or indirectly, to solve a problem. It must have a base case to terminate the calls.

Question 12 (a)

5 Marks [span_45](start_span)

Question: Write a C program to compute the sum of first n natural numbers using function.[span_45](end_span)

Solution:

 #include  int findSum(int n) { return (n * (n + 1)) / 2; } int main() { int n; printf("Enter a positive integer: "); scanf("%d", &n); printf("Sum of first %d natural numbers is %d\n", n, findSum(n)); return 0; } 

UNIT-V: Arrays

Question 13 (a)

1 Mark

Question: Write the syntax for declaring a two-dimensional array.

Solution:

data_type array_name[row_size][column_size];

Example: int matrix[3][3];

Question 13 (c)

1 Mark

Question: What is the first subscript of one-dimensional array in C?

Solution:

0

Question 15 (a)

5 Marks

Question: Write a program to find the largest element in an integer array.

Solution:

 #include  int main() { int arr[100], n, i, max; printf("Enter number of elements: "); scanf("%d", &n); printf("Enter %d elements:\n", n); for(i = 0; i < n; i++) { scanf("%d", &arr[i]); } max = arr[0]; for(i = 1; i < n; i++) { if(arr[i] > max) { max = arr[i]; } } printf("Largest element = %d\n", max); return 0; } 

Exam Focus Enhancements

Exam Tips

  • When writing programs, always include #include <stdio.h> and basic indentation for full marks.
  • For short syntax questions, always provide an example.

Common Mistakes

  • Confusing = (assignment) with == (equality) in if conditions.
  • Forgetting that array indices start at 0, not 1.

Important Formulas List

  • Sum of n natural numbers: n(n+1)/2
  • Condition for multiple: m % n == 0

Did this resource help you study?

Share feedback or report issues to help improve this resource.