University
SIGMA UNIVERSITY
Name
MAHESHKUMAR CHAUHAN
Mobile No
97126 12568
Designation
Teaching Assistant
Name of Program
Diploma in Chemical Engineering
Course Title
2DCO01 - Introduction to Computer Programming
Semester
Sem-2
Batch-3
Wednesday - Batch-3
Wednesday
10:30 to 12:20
Batch-2
Thursday - Batch-2
Thursday
15:00 to 16:50
Download
Suggested List of Experiments / Tutorials
Sr No.
Name of Experiment
Hours
1
Experiment to manage input and output operations
02
2
Write a program for Fibonacci series
02
3
Experiment to demonstrate operators and expressions
02
4
Experiment to demonstrate conditional statements and branching
06
5
Experiment to apply loops
04
6
Experiment to demonstrate working of one dimensional arrays
02
7
Experiment to demonstrate working of two dimensional arrays
02
8
Experiment to demonstrate working of strings
04
9
Experiment to implement user defined functions in C
02
10
Create a program to demonstrate call by value and return by value
02
11
Write a program to show nesting of function
02

1. Input and Output Operations

#include 

int main() {
    int a;
    printf("Enter a number: ");
    scanf("%d", &a);
    printf("You entered: %d", a);
    return 0;
}
Enter a number: 5 You entered: 5

2. Fibonacci Series

#include 

int main() {
    int n, a = 0, b = 1, c;
    printf("Enter number of terms: ");
    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        printf("%d ", a);
        c = a + b;
        a = b;
        b = c;
    }
    return 0;
}
Enter number of terms: 5 0 1 1 2 3

3. Operators and Expressions

#include 

int main() {
    int a = 10, b = 5;

    printf("Addition: %d\n", a + b);
    printf("Subtraction: %d\n", a - b);
    printf("Multiplication: %d\n", a * b);
    printf("Division: %d\n", a / b);
    printf("Modulus: %d\n", a % b);

    return 0;
}
Addition: 15 Subtraction: 5 Multiplication: 50 Division: 2 Modulus: 0

4. Conditional Statements and Branching

#include 

int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);

    if(num > 0)
        printf("Positive");
    else if(num < 0)
        printf("Negative");
    else
        printf("Zero");

    return 0;
}
Enter a number: -3 Negative

5. Loops (Sum of N Numbers)

#include 

int main() {
    int n, sum = 0;

    printf("Enter n: ");
    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        sum += i;
    }

    printf("Sum = %d", sum);
    return 0;
}
Enter n: 5 Sum = 15

6. One-Dimensional Array

#include 

int main() {
    int arr[5];

    printf("Enter 5 elements:\n");
    for(int i = 0; i < 5; i++) {
        scanf("%d", &arr[i]);
    }

    printf("Elements are:\n");
    for(int i = 0; i < 5; i++) {
        printf("%d ", arr[i]);
    }

    return 0;
}
Enter 5 elements: 1 2 3 4 5 Elements are: 1 2 3 4 5

7. Two-Dimensional Array

#include 

int main() {
    int a[2][2];

    printf("Enter elements:\n");
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            scanf("%d", &a[i][j]);
        }
    }

    printf("Matrix:\n");
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }

    return 0;
}
Enter elements: 1 2 3 4 Matrix: 1 2 3 4

8. Strings

#include 
#include 

int main() {
    char str[50];

    printf("Enter a string: ");
    scanf("%s", str);

    printf("Length = %lu", strlen(str));
    return 0;
}
Enter a string: Hello Length = 5

9. User Defined Function (Call by Value)

#include 

void add(int a, int b) {
    int sum = a + b;
    printf("Sum = %d", sum);
}

int main() {
    int x = 5, y = 3;
    add(x, y);
    return 0;
}
Sum = 8

10. Nesting of Functions

#include 

int square(int x) {
    return x * x;
}

int cube(int x) {
    return x * square(x);
}

int main() {
    int num = 3;
    printf("Cube = %d", cube(num));
    return 0;
}
Cube = 27