15 April 2026

Exercise Date; 15.04.2026

 1. 


int i, j;

scanf("%d", &no);
for(i=1; i<=no; i++)
{
        for(j=1; j<=no; j++)
        {
               printf("%d", i);
        }
        printf("\n");
}

2.

int i, j;

scanf("%d", &no);
for(i=1; i<=no; i++)
{
        for(j=1; j<=no; j++)
        {
               printf("%d", j);
        }
        printf("\n");

}


3. 

int i, j;

scanf("%d", &no);

for(i=1; i<=no; i++)

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

        {
               printf("%d", i);
        }

        printf("\n");
}


4. 

int i, j;

scanf("%d", &no);

for(i=1; i<=no; i++)

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

        {
               printf("%d", j);
        }

        printf("\n");

}


5. 

int i, j;

scanf("%d", &no);

for(i=1; i<=no; i++)

{

        for(j=1; j<=i; j++)

        {

               printf("%d", no-i);

        }

        printf("\n");

}


6. 

int i, j;

scanf("%d", &no);

for(i=1; i<=no; i++)

{

        for(j=1; j<=i; j++)

        {

               printf("%d", no-j);

        }

        printf("\n");

}


7. 

int i, j;

scanf("%d", &no);

for(i=no; i>=1; i--)

{

        for(j=i; j>=1; j--)

        {

               printf("%d", no-i);

        }

        printf("\n");

}


8. 

int i, j;

scanf("%d", &no);
for(i=no; i>=1; i--)
{
        for(j=i; j>=1; j--)
        {
               printf("%d", no-j);
        }
        printf("\n");

}

9. 

int i, j;

scanf("%d", &no);
for(i=no; i>=1; i--)
{
        for(j=1; j<=no-i; j++)
        {
               printf("%d", i);
        }
        printf("\n");

}

10. 

int i, j;

scanf("%d", &no);
for(i=no; i>=1; i--)
{
        for(j=1; j<=no-i; j++)
        {
               printf("%d", j);
        }
        printf("\n");


}

11. 

int i, j;

scanf("%d", &no);
for(i=no; i>=1; i--)
{
        for(j=1; j<=no-i; j++)
        {
               printf("%d", no-i);
        }
        printf("\n");


}

12. 

int i, j;

scanf("%d", &no);
for(i=no; i>=1; i--)
{
        for(j=1; j<=no-i; j++)
        {
               printf("%d", no-j);
        }
        printf("\n");


}                              


13. 

int i, j;

scanf("%d", &no);
for(i=1; i<=no; i++)
{
        for(j=1; j<=no; j++)
        {
               printf("%d", i);
        }
        for(j=1; j<=no; j++)
        {
               printf("%d", j);
        }
        printf("\n");
}

14. 

int i, j;

scanf("%d", &no);
for(i=1; i<=no; i++)
{
        for(j=1; j<=no-i; j++)
        {
               printf("%d", i);
        }
        for(j=no-i-1; j>=1; j--)
        {
               printf("%d", j);
        }
        printf("\n");
}

24 March 2026

Linked List Insert at END

#include<stdio.h>

#include<conio.h>


struct NODE

{

int data;

struct NODE *next;

};


typedef struct NODE node;


node *head, *end;

int count=0;


void insert_end();

void display();

void delete_end();


void main()

{

int ch;

clrscr();


do

{

printf("\n1. Insert Node at End");

printf("\n2. Display");

printf("\n3. Delete Node from End");

printf("\n4. Exit ");

printf("\n\nEnter your choice: ");

scanf("%d", &ch);


switch(ch)

{

case 1:

insert_end();

break;


case 2:

display();

getch();

break;


case 3:

delete_end();

break;


case 4:

break;


default:

printf("\n Please Enter Proper Choice");

break;


}

}while(ch != 4);

}


void insert_end()

{

node *temp;

temp=(node *)malloc(sizeof(node));


printf("\n Enter value for new node: ");

scanf("%d",&temp->data);

temp->next=NULL;


if(head==NULL)

head=temp;


end->next=temp;

end=temp;


count++;

}


void display()

{

node *temp;


if(count == 0)

printf("\n Please insert node first \n");

else

{

printf("\n You have inserted %d nodes",count);

printf("\n The next list as: ");


for(temp=head;temp !=NULL;temp=temp->next)

{

printf(" %d ",temp->data);

}

}

}


void delete_end()

{

node *temp;

int i;


if(count == 0)

printf("\n Please insert a node \n");

else

{

for(temp=head,i=1;i<count-1;temp=temp->next,i++);


temp->next=NULL;

printf("\n\n You have Deleted node %d\n\n", end->data);

free(end);

end=temp;

count--;

}

}


06 March 2026

Binary Search

 #include<stdio.h>

#include<conio.h>


void main()

{

int array[99], i, first, last, middle, n, search;

clrscr();


printf("Enter number of elements\n");

scanf("%d",&n);


printf("Enter Elements into the Array\n");

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

{

scanf("%d",&array[i]);

}


printf("Enter value to find\n");

scanf("%d",&search);


first = 0;

last = n - 1;

middle = (first+last) / 2;


while(first <= last)

{

if (array[middle] < search)

{

first = middle + 1;

}

else if(array[middle] == search)

{

printf("%d found at location %d\n", search, middle+1);

break;

}

else

{

last = middle - 1;

}

middle = (first + last)/2;

}

if(first > last)

{

printf("%d is not found in the list.\n", search);

}

getch();

}


Linear Search/ Sequential Search

 #include<stdio.h>

#include<conio.h>


void main()

{

int array[99], num, i, search, found=0;

clrscr();


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

scanf("%d", &num);


printf("Enter the elements one by one:\\n");

for (i = 0; i < num; i++)

{

scanf("%d", &array[i]);

}


printf("Enter the element to be searched: ");

scanf("%d", &search);


for (i = 0; i < num; i++)

{

if (search == array[i])

{

found = 1;

break;

}

}


if (found == 1)

{

printf("Element is present in the array at position %d\\n", i+1);

}

else

{

printf("Element is not present in the array\\n");

}


getch();

}


03 March 2026

Insertion Sort

 #include<stdio.h>

#include<conio.h>


void main()

{

int arr[99], no, i, j, temp;

clrscr();


printf("Enter number of elements: ");

scanf("%d", &no);


printf("Enter %d integers: ", no);

for (i = 0; i < no; i++)

{

scanf("%d", &arr[i]);

}


for (i = 1; i < no; i++)

{

temp = arr[i];

j = i - 1;


while (j >= 0 && arr[j] > temp)

{

arr[j + 1] = arr[j]; // Move element to the right

j = j - 1;           // Move to the previous element

}

// Move origional element into its correct position

arr[j + 1] = temp;

}


printf("Sorted elements:\n");

for (i = 0; i < no; i++)

{

printf("%d ", arr[i]);

}

printf("\n");


getch();

}


Selection Sort

#include<stdio.h>

#include<conio.h>


void main()

{

int a[99], no, i, j, min, temp;

clrscr();


printf("\nEnter size of an array: ");

scanf("%d", &no);


printf("\nEnter elements of an array:\n");

for(i=0; i<no; i++)

{

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

}


for (i=0; i<no; i++)

{

min = i;

for (j=i+1; j<no; j++)

{

if (a[j] < a[min])

min = j;

}

temp = a[i];

a[i] = a[min];

a[min] = temp;

}


printf("\n\nAfter sorting:\n");

for(i=0; i<no; i++)

{

printf("\n%d", a[i]);

}


getch();

}


Bubble Sort

 #include<stdio.h>

#include<conio.h>


void main()

{

int a[99],i,j,temp,no;

printf("\n Enter the max no.of Elements to Sort: \n");

scanf("%d",&no);

printf("\n Enter the Elements : \n");

for(i=0; i<no; i++)

{

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

}

for(i=0; i<no; i++)

{

for(j=i+1; j<no; j++)

{

if(a[i]>a[j])

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

}

for(i=0; i<no; i++)

{

printf("%d\t",a[i]);

}


getch();

}

20 February 2026

Double Ended Queue without Function

 #include<stdio.h>

#include<conio.h>


void main()

{

int deque[5], ch, i, value, front=-1, rear=-1;

clrscr();

do

{

printf("\nPress 1. insert at the beginning.");

printf("\nPress 2. insert at the end.");

printf("\nPress 3. delete from the beginning.");

printf("\nPress 4. delete from the end.");

printf("\nPress 5. display data.");

printf("\nPress 6. exit from the output screen.");

printf("\nEnter your choice:\n");

scanf("%d",&ch);


switch(ch)

{

case 1:


if(front==0 && rear==4)

{

printf("\nDeque is full.");

}

else

{

printf("\nEnter the data to be added at the beginning:\n");

scanf("%d",&value);

if(front==-1)

{

front=rear=0;

deque[front]=value;

}

/*If deque is full from the front only*/

else if(front==0 && rear!=4)

{

/*Shift the elements from 1 position to its right.*/

for(i=rear;i>=front;i--)

{

deque[i+1]=deque[i];

}

rear++;

deque[front]=value;

}

/*If deque is empty from the front.*/

else if(front>0)

{

front--;

deque[front]=value;

}

printf("\nNumber inserted at the beginning is %d",deque[front]);

}

break;


case 2:


if(front==0 && rear==4)

{

printf("\nDeque is full.");

}

else

{

printf("\nEnter the data to be added at the end:\n");

scanf("%d",&value);

if(rear==-1)

{

front=rear=0;

deque[rear]=value;

}

/*If deque is full from the end only*/

else if(front!=0 && rear==4)

{

/*Shift the elements from 1 position to its left.*/

for(i=front;i<=rear;i++)

{

deque[i-1]=deque[i];

}

front--;

deque[rear]=value;

}

/*If deque is empty from the end.*/

else if(rear<4)

{

rear++;

deque[rear]=value;

}

printf("\nNumber inserted at the end is %d",deque[rear]);

}

break;


case 3:

if(front==-1)

{

printf("Deque is empty.");

}

else

{

if(front==rear)

{

value=deque[front];

front=rear=-1;

}

else

{

value=deque[front];

front++;

}

}

printf("\nNumber deleted from the beginning is %d",value);


break;


case 4:

if(rear==-1)

{

printf("Deque is empty.");

}

else

{

if(front==rear)

{

value=deque[rear];

front=rear=-1;

}

else

{

value=deque[rear];

rear--;

}

}

printf("\nNumber deleted from the end is %d",value);


break;


case 5:


if(front==-1 || rear==-1)

{

printf("Deque is empty.");

}

else

{

for(i=front;i<=rear;i++)

{

printf("%5d",deque[i]);

}

}

break;


case 6:

exit(0);


default:

printf("\nYou have entered wrong choice!.");

}

}while(ch!=6);


getch();

}


11 November 2022

Array

 

Array:

 

#include<stdio.h>

#include<conio.h>

 

void main()

{

                int i, no[10];

                clrscr();

                printf(“Enter values in an array”);

                printf(“--------------------------------“);

 

                // Input/ Scan the numbers

                for(i=0; i<10; i++)

                {

                printf(“Enter value %d”, i+1);

                scanf(“%d”, &no[i]);

}

 

// Output/ Print the numbers

for(i=0; i<10; i++)

                {

                printf(“Value %d is %d”, i+1, no[i]);         

}

                getch();

}

 

 

Exercise:

1. Define an array of 5 employee. Enter the id number of 5 employee and print it.

2. Define an array of 5 students. Enter the percentage of 5 studnets and print it.

 

08 November 2022

C Programming Language Function Program

                                   Exercise Date: 08/11/2022

 

                                        For A&B Division                          

                                       Function Programs

 

Sr. No.

Program Definition

1

Define function with example. 

2

Define more than one function in one program.

3

Function calling function demo.

4

Recursion. Direct type demo.

5

Recursion. Indirect type demo.

6

Addition of two number using function.

(without return value, without argument)

7

Addition of two number using function.

(without return value, with argument)

8

Addition of two number using function.

(with return value, without argument)

9

Addition of two number using function.

(with return value, with argument)

10

Star print with function.

11

Function pattern print.

12

No return value, with argument: addition of three numbers

13

No return value, with argument: reverse number

14

No return value, with argument: square of number

15

No return value, No argument: swapping of two number

16

No return value, with argument: swapping of two number

17

with return value, no argument .. square of number

18

with return value, without argument ..  addition of two number

19

with return value, without argument .. reverse number

20

With return value, with argument .. square of number

21

With return value, with argument .. addition of two number

22

with return value, with argument .. reverse number

23

with return value, No argument: swapping of two number

24

with return value, with argument: swapping of two number

25

With return value, with argument: multiplication of three numbers

       

C Function Program Solutions 

===============================================