diff --git a/gaurav.122467/.vscode/settings.json b/gaurav.122467/.vscode/settings.json new file mode 100644 index 0000000..c8ef5a5 --- /dev/null +++ b/gaurav.122467/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "DSA1.C": "cpp" + } +} \ No newline at end of file diff --git a/gaurav.122467/DSA1 b/gaurav.122467/DSA1 new file mode 100755 index 0000000..39ea1e6 Binary files /dev/null and b/gaurav.122467/DSA1 differ diff --git a/gaurav.122467/DSA1.c b/gaurav.122467/DSA1.c new file mode 100644 index 0000000..a335a7a --- /dev/null +++ b/gaurav.122467/DSA1.c @@ -0,0 +1,76 @@ +//print the index number of a element in an array by binary searching. +#include +void sort(int a[],int size) +{ + int temp,j; + for(int i=0;ia[j+1]) + { + temp=a[j+1]; + a[j+1]=a[j]; + a[j]=temp; + } + } + } + printf("Sorting Done !\n"); + printf("New List Looks Like This :\n"); + for(int i=0;i elem) + { + hl=((hl+ll)/2)-1; + } + } + if(found == 1) + { + printf("Element not found"); + break; + } + } +} +int main() +{ + int len; + printf("Enter the length of array-: \n"); + scanf("%d",&len); + int a[len]; + printf("Enter %d numbers-: \n",len); + for(int i=0;i +void sort(int a[],int size) +{ + int temp; + for(int i=0;ia[j+1]) + { + temp=a[j+1]; + a[j+1]=a[j]; + a[j]=temp; + } + } + } +} +void print(int a[],int size) +{ + printf("Sorting Completed !\n"); + printf("New List Looks Like This :\n"); + for(int i=0;i +void search(int a[],int size) +{ + int elem=0,f=0; + printf("Enter element to be searched : \n"); + scanf("%d",&elem); + for(int i=0;i +void sort(int a[],int size) +{ + int temp; + for(int i=0;ia[j]) + { + temp=a[j]; + a[j]=a[i]; + a[i]=temp; + } + } + } +} +void print(int a[],int size) +{ + printf("Sorted Array is-: \n"); + for(int i=0;i +int fib(int c) +{ + if(c == 0) + { + return 0; + } + else if(c == 1) + { + return 1; + } + else + { + return ( fib(c-1) + fib(c-2) ); + } +} +int main() +{ + int c=0,l=0,lim=0; + printf("Enter Limit till which you want to calculate fibonacci series :\n"); + scanf("%d",&l); + printf("\n"); + for(int i=1;i<=l;i++) + { + printf("%d\n",fib(c)); + c++; + } + return 0; +} +/* 0 1 1 2 3 5 8 .... + a b c + a b c + a b c */ \ No newline at end of file diff --git a/gaurav.122467/DSA6 b/gaurav.122467/DSA6 new file mode 100755 index 0000000..3a121c5 Binary files /dev/null and b/gaurav.122467/DSA6 differ diff --git a/gaurav.122467/DSA6.c b/gaurav.122467/DSA6.c new file mode 100644 index 0000000..6123395 --- /dev/null +++ b/gaurav.122467/DSA6.c @@ -0,0 +1,39 @@ +#include +#include +void palindrome(char str[],int len) +{ + int p=1; + for(int i=0;i +void count(char str[],int len) +{ + int v=0,c=0; + for(int i=0;i<=len;i++) + { + if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u') + { + v++; + } + else + { + c++; + } + } + printf("No. of Vowels : %d\n",v); + printf("No. of Consonents : %d\n",c); +} +int main() +{ + int len=0; + char str[1000]; + printf("Enter string : \n"); + scanf("%s",str); + for(int i=1;i