Posts

Showing posts from January, 2021

Write a Program in c to implement Priority Queues using arrays

/* Write a Program in c to implement Priority Queues using arrays*/    #include<stdio.h> #include<conio.h> #define MAX 5 void insert_by_priority(int); void delete_by_priority(int); void create(); void check(int); void display_pqueue(); int pri_que[MAX]; int front, rear; void main() {     int n, ch;     printf("\n1 - Insert an element into queue");     printf("\n2 - Delete an element from queue");     printf("\n3 - Display queue elements");     printf("\n4 - Exit");     create();     while (1)     {         printf("\nEnter your choice : ");         scanf("%d", &ch);         switch (ch)         {         case 1:             printf("\nEnter value to be inserted : ");             scanf("%d",&n);             insert_by_priority(n);             break;         case 2:             printf("\nEnter value to delete : ");             scanf("%d",&n);             delete_by_prior

Write a Program in c that implement Queue and its operations ( insertion and deletion ) using linked lists

/* Write a Program in c  that implement Queue and its operations ( insertion and deletion ) using   linked lists */ #include <stdio.h> #include <stdlib.h> struct node {     int info;     struct node *ptr; }*front,*rear,*temp,*front1; void enq(int data); void deq(); void empty(); int count = 0; void main() {     int no, ch, e;     printf("\n 1 - Enque");     printf("\n 2 - Deque");     printf("\n 3 - Exit");     printf("\n 4 - Display");     while (1)     {         printf("\n Enter choice : ");         scanf("%d", &ch);         switch (ch)         {         case 1:             printf("Enter data : ");             scanf("%d", &no);             enq(no);             break;         case 2:             deq();             break;         case 3:             exit(0);         case 4:             display();             break;         default:             printf("Wrong choice, Please enter corr

Write a Program in c that implement Queue and its operations ( insertion and deletion ) using arrays

/* Write a Program in c that implement Queue and its operations ( insertion and deletion ) using   arrays*/   #include <stdio.h> #define MAX 50 void insert(); void delete(); void display(); int queue_array[MAX]; int rear = - 1; int front = - 1; main() {     int choice;     while (1)     {         printf("\n 1.Insert element to queue \n");         printf("\n 2.Delete element from queue \n");         printf("\n 3.Display all elements of queue \n");         printf("\n 4.Quit \n");         printf("\n Enter your choice : \n");         scanf("%d", &choice);         switch (choice)         {             case 1:             insert();             break;             case 2:             delete();             break;             case 3:             display();             break;             case 4:             exit(1);             default:             printf("Wrong choice \n");         } /* End of switch */     } /* End

Write a Program in c that implement stack and its operations (push and pop) using Linked list

/* Write a Program in c that implement stack and its operations (push and pop) using Linked list*/       #include <stdio.h>       #include <stdlib.h>       void push();       void pop();       void display();       struct node        {       int val;       struct node *next;       };       struct node *head;              void main ()       {           int choice=0;              printf("\n*********Stack operations using linked list*********\n");           printf("\n----------------------------------------------\n");           while(choice != 4)           {               printf("\n\nChose one from the below options...\n");               printf("\n1.Push\n2.Pop\n3.Show\n4.Exit");               printf("\n Enter your choice \n");                     scanf("%d",&choice);               switch(choice)               {                   case 1:                   {                        push();                       brea

Write a Program in c that implement stack and its operations (push and pop) using arrays

/* Write a Program in c that implement stack and its operations (push and pop) using arrays*/   #include<stdio.h> #include<conio.h> int stack[100],choice,n,top,x,i; void push(void); void pop(void); void display(void); int main() {          top=-1;     printf("\n Enter the size of STACK[MAX=100]:");     scanf("%d",&n);     printf("\n\t STACK OPERATIONS USING ARRAY");     printf("\n\t--------------------------------");     printf("\n\t 1.PUSH\n\t 2.POP\n\t 3.DISPLAY\n\t 4.EXIT");     do     {         printf("\n Enter the Choice:");         scanf("%d",&choice);         switch(choice)         {             case 1:             {                 push();                 break;             }             case 2:             {                 pop();                 break;             }             case 3:             {                 display();                 break;             }             case 4:      

Write a Program that uses functions to' perform insertion operation on a singly linked list. Write a Program that uses functions to perform deletion operation on a singly linked list

/* Write a Program that uses functions to' perform insertion operation on a singly linked   list.  & Write a Program that uses functions to perform deletion operation on a singly linked list*/    #include<stdlib.h> #include <stdio.h> void display(); void insert_begin(); void delete_begin(); struct node {         int info;         struct node *next; }; struct node *start=NULL; int main() {         int choice;         while(1){                 printf("\n                MENU       \n");                 printf("\n 1.Display    \n");                 printf("\n 2.Insert at the beginning    \n");                 printf("\n 3.Delete from beginning      \n");                 printf("\n 4.Exit       \n");                 printf("\n------------------------------------\n");                 printf("\nEnter your choice: \n");                 scanf("%d",&choice);                 switch(choice)     

Write a Program that implement selection sort, to sort a given list of integers in ascending order

 /* Write a Program that implement selection sort, to sort a given list of integers in ascending order */ #include<stdio.h> #include<conio.h> #include<stdlib.h> main() { int a[10],i,j,n,temp; printf(" enter no of array elements : \n"); scanf("%d",&n); printf(" enter unsorted %d elements  \n",n); for(i=1;i<=n;i++) { scanf("%d",&a[i]); } for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { if(a[i] > a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf("sorted array after selection sort : \n"); for(i=1;i<=n;i++) { printf("\n  %d ", a[i]); } getch(); }

Write a Program in c that implement insertion sort, to sort a given list of integers in ascending order

/* Write a Program in c that implement insertion sort, to sort a given list of integers in   ascending order*/  #include<stdio.h> #include<conio.h> #include<stdlib.h> main() { int array[10],n,j,i,t; printf(" enter no of array elements : \n"); scanf("%d",&n); printf(" enter unsorted  %d elements  \n",n); for(i=1;i<=n;i++) { scanf("%d",&array[i]); } for(i=1;i<=n;i++) { for(j=2;j<=n;j++) { if(array[j] < array[j-1]) { t=array[j]; array[j]=array[j-1]; array[j-1]=t; } } } printf("SORTED ARRAY AFTER INSERTION SORT :  \n " ); for(i=1;i<=n;i++) { printf("%d \n", array[i]); } getch(); }

Write a Program in c that implement Bubble sort, to sort a given list of integers in ascending order

/* Write a Program in c that implement Bubble sort, to sort a given list of integers in ascending   order*/   #include<stdio.h> #include<conio.h> #include<stdlib.h> main() { int arr[10],i,j,n,temp; printf("Enter array size:  "); scanf("%d",&n); printf("enter array elements for bubble sort :  "); for(i=1;i<=n;i++) { scanf("%d",&arr[i]); printf("\n "); } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(arr[j]>arr[j+1]){ temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } printf("array after applying bubble sort : "); for(i=1;i<=n;i++){ printf("\n %d \n ",arr[i]); } getch(); }  

Write a Program to perform in c Binary search for a given value in a sorted list

/* Write a Program to perform in c Binary search for a given value in a sorted list*/ #include <stdio.h> int main() {   int i, first, last, middle, n, item, la[100];   printf("Enter number of elements\n");   scanf("%d", &n);   printf("Enter %d integers\n", n);   for (i = 1; i <= n; i++)     scanf("%d", &la[i]);   printf("Enter value to find\n");   scanf("%d", &item);   first = 1;   last = n;   middle = (first+last)/2;   while (first <= last) {     if(la[middle] == item)     {         printf("found ");         break;     }       else if (item>la[middle])     {       first = middle + 1;     }     else     {       last = middle - 1;     }     middle = (first + last)/2;   }   if (first > last)     printf("Not found");   return 0; }  

Write a Program in c to perform linear search for a given value in a unsorted list

/* Write a Program in c to perform linear search for a given value in a unsorted list*/   #include<stdio.h> #include<conio.h> #include<stdlib.h> main() { int arr[100],i,n,value; printf("Enter array size:  "); scanf("%d",&n); printf("enter array elements :  "); for(i=1;i<=n;i++) { scanf("%d",&arr[i]); printf("\n "); } printf("enter the value for searching its loc:  "); scanf("%d",&value); printf("location found after linear sereach :  "); for(i=1;i<=n;i++) { if(arr[i]==value) printf("%d ",i); } getch(); }

Write a program in c to calculate sum of ten numbers using array

/* Write a program in c to calculate sum of ten numbers using array*/   #include<stdio.h> void main() { int arr[100],i,sum=0; printf("\n C Program to add 10 numbers using arrays : \n\n"); for(i = 1; i<=10;i++)  {       scanf("%d",&arr[i]);  } for(i = 1; i<=10;i++)  {        sum = sum + arr[i];  } printf("\n sum of all 10 numbers is : %d",sum); }

Write a recursive and non recursive program in c to display the Fibonacci sequence.

/* Write a recursive and non recursive program to display the Fibonacci sequence*/ #include<stdio.h> int rfib(int n) {     if(n == 1)         return 0;     else if(n == 2)         return 1;     else     {         return rfib(n - 1) + rfib(n - 2);     } } int main() {  int n1=0,n2=1,n3,i,number;  printf("Enter the number of elements or terms:");  scanf("%d",&number);  printf("\n ***fibonacci sequence without recursion:");  printf("\n%d %d",n1,n2);//printing 0 and 1  for(i=2;i<number;i++    )//loop starts from 2 because 0 and 1 are already printed  {   n3=n1+n2;   printf(" %d",n3);   n1=n2;   n2=n3;  }  printf("\n \n***fibonacci sequence with recursion:");  for(int i=1;i<=number;i++)  {      printf("\n %d \n",rfib(i));  }    return 0;  }  

recursive and non recursive program in c to calculate the factorial of a number

 #include <stdio.h>   /*recursive and non recursive program in c to calculate the factorial of a number*/ #include <stdlib.h> int main() {     int n,x,y;     printf("Q. enter the number to find its factorial:");     scanf("%d",&n);     x=recfact(n);     printf("\n 1. recursive factorial of number is :%d \n",x);     y=nonrecfact(n);     printf("\n 2. nonrecursive factorial of number is :%d \n",y);     return 0; } int recfact(int n) {     if(n==0)         return(1);     else         return(n*recfact(n-1)); } int nonrecfact(int n) {     int i,f=1;     for(i=1;i<=n;i++)     {         f=f*i;     }     return(f); }

shri guru charitra gurucharitra in english

Shri Guru Charitra  Introduction 1  Shri Guru-Charitra, a religious book giving a brief life story of "Shri Nrusimha Saraswati Swami  Maharaj", was written in the 15th Century by one of his closest disciples. This book is a treasure house of  religious events related to the life of Shri Nrusimha Saraswati. It is read with great reverence by the  devotees of Lord Shri Dattatreya.  The 'Shri Guru Charitra' is the life of 'Shri Guru Dattatreya' (an incarnation of Brahma, Vishnu and  Maheshwara). It was originally written in Ovi form (a Marathi Metre) in Marathi by Shri Saraswati  Gangadhar, whose ancestor Sayamdev had personally lived and served with devotion, Guru Narasimha  Saraswati, an incarnation of Shri Dattatreya about 600 years ago. It was later translated into Sanskrit by  Shri Vasudevananda Saraswati (Tembye Swamy), who is regarded by many as an incarnation of Shri  Dattatreya and who lived about a hundred years ago. It has been later translated into se