Posts

Showing posts from June, 2020

Featured post

-Write C program to find even and odd number using macro

-Write C program to find even and odd number using macro #include<stdio.h> #define number(n)((n%2==0)?1:0) int main() { int num; printf("enter any number"); scanf("%d",&num); if(number(num)) printf("number is even"); else printf("number is odd"); return 0; } ***************************Output*********************** amr@amrj-virtual-machine:~$ gccevenodd.c amr@samr-virtual-machine:~$ ./a.out enter any number 2 number is evensmj@amr-virtual-machine:~$

Write a program to find the Seven elements using Quick Sort in c(Data Structure and Algorithm).

                                                      DATA STRUCTURE AND ALGORITHM Write a program to find the  Seven elements using Quick Sort in c(Data Structure and Algorithm).   #include<stdio.h> void quick_sort(int a[10],int low,int high); void main() {   int pivot,high,low,i,j,n,a[10]; printf("how many element you want to sort"); scanf("%d",&n); printf("enter the element of an array"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } quick_sort(a,0,n-1); low=0; high=n-1; quick_sort(a,low,high); printf("after sorting the element are"); for(i=0;i<n;i++) printf("%d\t",a[i]); } void quick_sort(int a[10],int low,int high) {   int pivot,i,j,t; if(low<high) { pivot=a[low]; i=low; j=high; while(i<j) { while(pivot>...

Write a C Program to find the Adjacency List in C (Data Structure )

                        DATA STRUCTURE AND ALGORITHM     Write a C Program to find the Adjacency List in C (Data Structure ) struct node //If you  have plzz write the Header file { int vertex; struct node *next; }*v[10]; void create(int m[20][20],int n) { int i,j; char ans; for(i=0;i<n;i++) for(j=0;j<n;j++) { printf("is there an edge between %d and %d",i+1,j+1); scanf("%d",&m[i][j]); } } void disp(int m[20][20],int n) { int i,j; printf("\nthe adjancy matrix is:\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%d",m[i][j]); printf("\n"); } } void create1(int m[20][20],int n) { int i,j; struct node *temp,*newnode; for(i=0;i<n;i++) { v[i]=NULL; for(j=0;j<n;j++) { if(m[i][j]==1) { newnode=(struct node *)malloc(sizeof(struct node)); newnode->next=NULL; newnode->vertex=j+1; if(v[i]==NULL) v[i]=tem...

Write a program find the Intersection of two linked list in C program (Data Structure and Algorithm.)

Data Structure and Algorithm     Write a program find the  Intersection of two linked list in Data Structure. #include <stdio.h>  #include <stdlib.h>  struct node{                                                                                                                                                            struct node *next;                                                                  ...