Nepal's open education portal

EduNepalEduNepal

C Programming — Complete Course Notes (BCA 1st Sem)

Comprehensive master notes covering fundamentals, syntax, control statements, arrays, pointers, structures, and file I/O for TU BCA 1st semester.

C Programming · CACS101 · Semester 1

BCA Curriculum 2079

Unit 5•Unit 5 of 6

Unit 5: 4. Control Statements & Decision Making

If-Else Decision Making:

```c #include <stdio.h>

int main() { int score; printf("Enter exam marks (0-100): "); scanf("%d", &score);

if (score >= 80) { printf("Grade: Distinction\n"); } else if (score >= 60) { printf("Grade: First Division\n"); } else if (score >= 40) { printf("Grade: Pass\n"); } else { printf("Grade: Fail\n"); } return 0; } ```

Related notes

View all →

Related video lessons

View all →

Practice questions

View all →
  • Which of the following is an invalid variable name in C? (a) _salary (b) 1st_rank (c) total_sum (d) age2objective · 1 marks
  • What is the return type of the `malloc()` function in C? (a) `int*` (b) `char*` (c) `void*` (d) `float*`objective · 1 marks
  • Explain the difference between call by value and call by reference in C with suitable code snippets.short · 5 marks
  • What is recursion? Write a recursive function in C to calculate the factorial of a positive integer.short · 5 marks
  • Explain dynamic memory allocation in C. Differentiate between `malloc()` and `calloc()`. Write a C program to dynamically allocate memory for N integers, sort them in ascending order, and free the memory.long · 10 marks

View all questions for this subject →

← Back to all notes