From 4d7ca350bb9a08fd43d8b9a61459db5dcdeb753d Mon Sep 17 00:00:00 2001 From: Suvidha Date: Fri, 7 Nov 2025 10:56:42 +0530 Subject: [PATCH] BST(Binary Search Tree) program in C --- .gitignore | 52 --- 2Darray.c | 28 -- Analogclock.c | 126 ------- Appending_Node.c | 69 ---- Area of circle | 27 -- ArmstrongNumber | 27 -- BubbleSort.c | 45 --- Calculator.c | 36 -- DMA.c | 32 -- EVEN ODD SUM ARRAY.cpp | 25 -- FILE.txt | 1 - Hexadecimal To Decimal in C | 37 -- InsertionSort.c | 29 -- Insertion_sort.c | 42 --- LCF | 16 - LICENSE | 674 ------------------------------------ LL(Insertion At Begining).c | 57 --- LinerSearchAlgo(Binary).c | 48 --- LinerSearchAlgo.c | 41 --- Linked List | 133 ------- Merge Sort in C. | 140 -------- README.md | 11 - RECRSION | 25 -- RECURSION | 25 -- Sparse Matrix | 68 ---- Stack.c | 92 ----- Sum_Diagnols.c | 40 --- TRANSPOSE_0FMATRIX.c | 28 -- Take input from user | 25 -- TicTacToe.c | 228 ------------ Vowel or not | 35 -- add.c | 13 - additionarray.c | 24 -- armstrong.c | 24 -- armstrong_number.cpp | 48 --- armstronginrange.c | 26 -- array10number.c | 17 - average.c | 13 - averagealt.c | 15 - binary_insertion_sort.cpp | 39 --- binary_search_of_strings.c | 74 ---- bst_program.c | 246 +++++++++++++ bubble sort.cpp | 32 -- calculator.c | 32 -- countdigit.c | 18 - difference.c | 29 -- divide.c | 11 - divisionalt.c | 16 - divisionarray.c | 27 -- dowhile50.c | 11 - even.c | 17 - evenarray.c | 21 -- factorial.c | 14 - factors.c | 17 - fibonacci.c | 18 - fibonacci1.c | 20 -- fileHandling.c | 52 --- fileHandlingSimple.c | 37 -- find_leap_year.c | 29 -- first&lastdigit.c | 22 -- frequency.c | 19 - function50even(1).c | 17 - function50even.c | 17 - functionadd(1).c | 19 - functionadd.c | 19 - functionadd1(1).c | 18 - functionadd1.c | 18 - functionadd2.c(1).c | 20 -- functionadd2.c.c | 20 -- functionadd3(1).c | 22 -- functionadd3.c | 22 -- functionarmstrong(1).c | 34 -- functionarmstrong.c | 34 -- functionaverage(1).c | 19 - functionaverage.c | 19 - functionaverage1(1).c | 24 -- functionaverage1.c | 24 -- functioncount(1).c | 21 -- functioncount.c | 21 -- functiondivide1(1).c | 18 - functiondivide1.c | 18 - functiondivide2(1).c | 20 -- functiondivide2.c | 20 -- functiondivision(1).c | 19 - functiondivision.c | 19 - functiondivision3(1).c | 24 -- functiondivision3.c | 24 -- functionevenodd(1).c | 23 -- functionevenodd.c | 23 -- functionevenodd1(1).c | 30 -- functionevenodd1.c | 30 -- functionfact(1).c | 20 -- functionfact.c | 20 -- functionfibonacci(1).c | 28 -- functionfibonacci.c | 28 -- functionfirst&last.c | 34 -- functionfreq.c | 25 -- functionhcflcm(1).c | 41 --- functionhcflcm.c | 41 --- functionisLargest(1).c | 19 - functionisLargest.c | 19 - functionisLargest3(1).c | 27 -- functionisLargest3.c | 27 -- functionnum50(1).c | 14 - functionnum50.c | 14 - functionpalindrome(1).c | 31 -- functionpalindrome.c | 30 -- functionposneg(1).c | 32 -- functionposneg.c | 32 -- functionprime(1).c | 32 -- functionprime.c | 32 -- functionprimeinrange(1).c | 30 -- functionprimeinrange.c | 31 -- functionproduct(1).c | 20 -- functionproduct.c | 20 -- functionproduct1(1).c | 23 -- functionproduct1.c | 23 -- functionproduct2(1).c | 19 - functionproduct2.c | 19 - functionproduct3(1).c | 22 -- functionproduct3.c | 22 -- functionquadratic(1).c | 39 --- functionquadratic(2).c | 39 --- functionquadratic.c | 39 --- functionreverse(1).c | 20 -- functionreverse.c | 20 -- functionreverse1(1).c | 23 -- functionreverse1.c | 23 -- functionseriessum.c | 24 -- functionsubtract(1).c | 20 -- functionsubtract.c | 20 -- functionsubtract1(1).c | 19 - functionsubtract1.c | 19 - functionsubtract2(1).c | 20 -- functionsubtract2.c | 20 -- functionsubtract3(1).c | 23 -- functionsubtract3.c | 23 -- functionsum100(1).c | 18 - guessTheNumber.c | 32 -- hcf&lcm.c | 22 -- ifelseLadder.c | 25 -- largestthree.c | 28 -- largesttwo.c | 18 - mult.c | 11 - palindrome using c | 19 - palindrome.c | 22 -- percentage.c | 16 - percentagealt.c | 15 - pointer.c | 14 - pointersToIntegers.c | 20 -- posnegative.c | 22 -- prime.c | 27 -- primeinrange.c | 25 -- print50.c | 9 - printeven.c | 8 - productdigits.c | 17 - quadratic.c | 28 -- reverse.c | 15 - reversenatural.c | 14 - reversewhile.c | 17 - seriessum.c | 18 - subjectsarray.c | 18 - subtract1array.c | 24 -- subtractarray.c | 24 -- sumeven.c | 14 - sumnatural.c | 12 - sumodd.c | 14 - sumofldfd.c | 20 -- swappedfirst&last.c | 23 -- swapping.c | 14 - table.c | 13 - table10num.c | 17 - table2.c | 13 - vowel.c | 17 - while50.c | 10 - whileseries.c | 18 - whileven.c | 16 - 177 files changed, 246 insertions(+), 5546 deletions(-) delete mode 100644 .gitignore delete mode 100644 2Darray.c delete mode 100644 Analogclock.c delete mode 100644 Appending_Node.c delete mode 100644 Area of circle delete mode 100644 ArmstrongNumber delete mode 100644 BubbleSort.c delete mode 100644 Calculator.c delete mode 100644 DMA.c delete mode 100644 EVEN ODD SUM ARRAY.cpp delete mode 100644 FILE.txt delete mode 100644 Hexadecimal To Decimal in C delete mode 100644 InsertionSort.c delete mode 100644 Insertion_sort.c delete mode 100644 LCF delete mode 100644 LICENSE delete mode 100644 LL(Insertion At Begining).c delete mode 100644 LinerSearchAlgo(Binary).c delete mode 100644 LinerSearchAlgo.c delete mode 100644 Linked List delete mode 100644 Merge Sort in C. delete mode 100644 README.md delete mode 100644 RECRSION delete mode 100644 RECURSION delete mode 100644 Sparse Matrix delete mode 100644 Stack.c delete mode 100644 Sum_Diagnols.c delete mode 100644 TRANSPOSE_0FMATRIX.c delete mode 100644 Take input from user delete mode 100644 TicTacToe.c delete mode 100644 Vowel or not delete mode 100644 add.c delete mode 100644 additionarray.c delete mode 100644 armstrong.c delete mode 100644 armstrong_number.cpp delete mode 100644 armstronginrange.c delete mode 100644 array10number.c delete mode 100644 average.c delete mode 100644 averagealt.c delete mode 100644 binary_insertion_sort.cpp delete mode 100644 binary_search_of_strings.c create mode 100644 bst_program.c delete mode 100644 bubble sort.cpp delete mode 100644 calculator.c delete mode 100644 countdigit.c delete mode 100644 difference.c delete mode 100644 divide.c delete mode 100644 divisionalt.c delete mode 100644 divisionarray.c delete mode 100644 dowhile50.c delete mode 100644 even.c delete mode 100644 evenarray.c delete mode 100644 factorial.c delete mode 100644 factors.c delete mode 100644 fibonacci.c delete mode 100644 fibonacci1.c delete mode 100644 fileHandling.c delete mode 100644 fileHandlingSimple.c delete mode 100644 find_leap_year.c delete mode 100644 first&lastdigit.c delete mode 100644 frequency.c delete mode 100644 function50even(1).c delete mode 100644 function50even.c delete mode 100644 functionadd(1).c delete mode 100644 functionadd.c delete mode 100644 functionadd1(1).c delete mode 100644 functionadd1.c delete mode 100644 functionadd2.c(1).c delete mode 100644 functionadd2.c.c delete mode 100644 functionadd3(1).c delete mode 100644 functionadd3.c delete mode 100644 functionarmstrong(1).c delete mode 100644 functionarmstrong.c delete mode 100644 functionaverage(1).c delete mode 100644 functionaverage.c delete mode 100644 functionaverage1(1).c delete mode 100644 functionaverage1.c delete mode 100644 functioncount(1).c delete mode 100644 functioncount.c delete mode 100644 functiondivide1(1).c delete mode 100644 functiondivide1.c delete mode 100644 functiondivide2(1).c delete mode 100644 functiondivide2.c delete mode 100644 functiondivision(1).c delete mode 100644 functiondivision.c delete mode 100644 functiondivision3(1).c delete mode 100644 functiondivision3.c delete mode 100644 functionevenodd(1).c delete mode 100644 functionevenodd.c delete mode 100644 functionevenodd1(1).c delete mode 100644 functionevenodd1.c delete mode 100644 functionfact(1).c delete mode 100644 functionfact.c delete mode 100644 functionfibonacci(1).c delete mode 100644 functionfibonacci.c delete mode 100644 functionfirst&last.c delete mode 100644 functionfreq.c delete mode 100644 functionhcflcm(1).c delete mode 100644 functionhcflcm.c delete mode 100644 functionisLargest(1).c delete mode 100644 functionisLargest.c delete mode 100644 functionisLargest3(1).c delete mode 100644 functionisLargest3.c delete mode 100644 functionnum50(1).c delete mode 100644 functionnum50.c delete mode 100644 functionpalindrome(1).c delete mode 100644 functionpalindrome.c delete mode 100644 functionposneg(1).c delete mode 100644 functionposneg.c delete mode 100644 functionprime(1).c delete mode 100644 functionprime.c delete mode 100644 functionprimeinrange(1).c delete mode 100644 functionprimeinrange.c delete mode 100644 functionproduct(1).c delete mode 100644 functionproduct.c delete mode 100644 functionproduct1(1).c delete mode 100644 functionproduct1.c delete mode 100644 functionproduct2(1).c delete mode 100644 functionproduct2.c delete mode 100644 functionproduct3(1).c delete mode 100644 functionproduct3.c delete mode 100644 functionquadratic(1).c delete mode 100644 functionquadratic(2).c delete mode 100644 functionquadratic.c delete mode 100644 functionreverse(1).c delete mode 100644 functionreverse.c delete mode 100644 functionreverse1(1).c delete mode 100644 functionreverse1.c delete mode 100644 functionseriessum.c delete mode 100644 functionsubtract(1).c delete mode 100644 functionsubtract.c delete mode 100644 functionsubtract1(1).c delete mode 100644 functionsubtract1.c delete mode 100644 functionsubtract2(1).c delete mode 100644 functionsubtract2.c delete mode 100644 functionsubtract3(1).c delete mode 100644 functionsubtract3.c delete mode 100644 functionsum100(1).c delete mode 100644 guessTheNumber.c delete mode 100644 hcf&lcm.c delete mode 100644 ifelseLadder.c delete mode 100644 largestthree.c delete mode 100644 largesttwo.c delete mode 100644 mult.c delete mode 100644 palindrome using c delete mode 100644 palindrome.c delete mode 100644 percentage.c delete mode 100644 percentagealt.c delete mode 100644 pointer.c delete mode 100644 pointersToIntegers.c delete mode 100644 posnegative.c delete mode 100644 prime.c delete mode 100644 primeinrange.c delete mode 100644 print50.c delete mode 100644 printeven.c delete mode 100644 productdigits.c delete mode 100644 quadratic.c delete mode 100644 reverse.c delete mode 100644 reversenatural.c delete mode 100644 reversewhile.c delete mode 100644 seriessum.c delete mode 100644 subjectsarray.c delete mode 100644 subtract1array.c delete mode 100644 subtractarray.c delete mode 100644 sumeven.c delete mode 100644 sumnatural.c delete mode 100644 sumodd.c delete mode 100644 sumofldfd.c delete mode 100644 swappedfirst&last.c delete mode 100644 swapping.c delete mode 100644 table.c delete mode 100644 table10num.c delete mode 100644 table2.c delete mode 100644 vowel.c delete mode 100644 while50.c delete mode 100644 whileseries.c delete mode 100644 whileven.c diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c6127b3..0000000 --- a/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/2Darray.c b/2Darray.c deleted file mode 100644 index 7f6cab6..0000000 --- a/2Darray.c +++ /dev/null @@ -1,28 +0,0 @@ -/*C program to input 2-D array of size 3*5.The -display the matrix*/ - -#include -int main() -{ - int a[3][5]; - int i,j; - printf("Enter the elements:"); - for(i=0;i<=2;i++) - { - for(j=0;j<=4;j++) - { - scanf("%d",&a[i][j]); - } - } - printf("Elements are\n"); - for(i=0;i<=2;i++) - { - for(j=0;j<=4;j++) - { - printf("%d\t",a[i][j]); - } - printf("\n"); - - } - return 0; -} diff --git a/Analogclock.c b/Analogclock.c deleted file mode 100644 index a739c0b..0000000 --- a/Analogclock.c +++ /dev/null @@ -1,126 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -#define PI 3.147 - -void clockLayout(); -void secHand(); -void hrHand(); -void minHand(); -int maxx,maxy; - -void main() -{ - int gdriver=DETECT,gmode,error; - initgraph(&gdriver,&gmode,"c:\turboc3\bgi\"); - error=graphresult(); - if(error!=grOk) - { - printf("Error in graphics, code= %d",grapherrormsg(error)); - exit(0); - } - - while(1) - { - clockLayout(); - secHand(); - minHand(); - hrHand(); - sleep(1); /* pausing the outputscreen for 1 sec */ - cleardevice(); /* clearing the previous picture of clock */ - } -} - -void clockLayout() -{ - int i,x,y,r; - float j; - maxx=getmaxx(); - maxy=getmaxy(); - - for(i=1;i<5;i++) - { /* printing a round ring with outer radius of 5 pixel */ - setcolor(YELLOW); - circle(maxx/2,maxy/2,120-i); - } - - pieslice(maxx/2,maxy/2,0,360,5); /* displaying a circle in the middle of clock */ - x=maxx/2+100;y=maxy/2; - r=100; - setcolor(BLUE); - - for(j=PI/6;j<=(2*PI);j+=(PI/6)) - { /* marking the hours for every 30 degrees */ - pieslice(x,y,0,360,4); - x=(maxx/2)+r*cos(j); - y=(maxy/2)+r*sin(j); - } - - x=maxx/2+100;y=maxy/2; - r=100; - setcolor(RED); - - for(j=PI/30;j<=(2*PI);j+=(PI/30)) - { /* marking the minutes for every 6 degrees */ - pieslice(x,y,0,360,2); - x=(maxx/2)+r*cos(j); - y=(maxy/2)+r*sin(j); - } -} - -void secHand() -{ - struct time t; - int r=80,x=maxx/2,y=maxy/2,sec; - float O; - - maxx=getmaxx();maxy=getmaxy(); - gettime(&t); /*getting the seconds in system clock */ - sec=t.ti_sec; - O=sec*(PI/30)-(PI/2); /* determining the angle of the line with respect to vertical */ - setcolor(YELLOW); - line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O)); -} - -void hrHand() -{ - int r=50,hr,min; - int x,y; - struct time t; - float O; - - maxx=getmaxx(); - maxy=getmaxy(); - x=maxx/2,y=maxy/2; - gettime(&t); /*getting the seconds in system clock */ - hr=t.ti_hour; - min=t.ti_min; - - /* determining the angle of the line with respect to vertical */ - if(hr<=12)O=(hr*(PI/6)-(PI/2))+((min/12)*(PI/30)); - if(hr>12) O=((hr-12)*(PI/6)-(PI/2))+((min/12)*(PI/30)); - setcolor(BLUE); - line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O)); -} - -void minHand() -{ - int r=60,min; - int x,y; - float O; - struct time t; - maxx=getmaxx(); - maxy=getmaxy(); - x=maxx/2; - y=maxy/2; - gettime(&t); /*getting the seconds in system clock */ - min=t.ti_min; - O=(min*(PI/30)-(PI/2)); /* determining the angle of the line with respect to vertical */ - setcolor(RED); - line(maxx/2,maxy/2,x+r*cos(O),y+r*sin(O)); - } diff --git a/Appending_Node.c b/Appending_Node.c deleted file mode 100644 index 4d9e308..0000000 --- a/Appending_Node.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -void append(); -struct node -{ - int data; - struct node *link; -}; -struct node *root; -int main() -{ - root=(struct node*)malloc(sizeof(struct node)); - - printf("ROOT 1 DATA:"); - scanf("%d", &root->data); - root->link=NULL; - - struct node*current; - current=(struct node*)malloc(sizeof(struct node)); - - - printf("ROOT 2 DATA:"); - scanf("%d", ¤t->data); - current->link=NULL; - root->link=current; // this will store the address of the second node into the link part of the first node - - current=malloc(sizeof(struct node)); - - printf("ROOT 3 DATA:"); - scanf("%d", ¤t->data); - current->link=NULL; - root->link->link=current; // this will store the base address of the third node into the link part of the second node - - printf("APPENDING NODE:\n"); - append(); // now the user will be prompted for appending the element to the last of the linked list - -} - -void append() -{ - struct node *temp; - temp=(struct node*)malloc(sizeof(struct node)); - printf("ENTER NODE DATA:"); - scanf("%d", &temp->data); - - if(root==NULL) - { - root=temp; // we are checking if the linked list is empty then this will be the first node to be inserted in the linked list - } - - else - { - struct node *ptr; // used for traversing through nodes - ptr=root; - while(ptr->link!=NULL) - { - ptr=ptr->link; - } - ptr->link=temp; // this will connect the last node with the temp node which we created before - } - - printf("PRINTING DATA IN ALL NODES\n"); - - printf("NODE 1: %d\n", root->data); - printf("NODE 2: %d\n", root->link->data); - printf("NODE 3: %d\n", root->link->link->data); - printf("NODE 4: %d\n", root->link->link->link->data); - -} \ No newline at end of file diff --git a/Area of circle b/Area of circle deleted file mode 100644 index 03d3332..0000000 --- a/Area of circle +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#define pi 3.1415 - - //Function declaration - float areaOfcircle(float radius_circle); - - int main() { - float radius; - - // take radius as input - printf("Enter the radius of circle : "); - scanf("%f", &radius); - - printf("Area of circle : %.2f", areaOfcircle(radius)); - printf("\n"); - - return 0; -} - -// function definition to calculate area of circle -float areaOfcircle(float radius_circle){ - float area_circle; - area_circle = 3.14 * radius_circle * radius_circle; - - return area_circle; -} diff --git a/ArmstrongNumber b/ArmstrongNumber deleted file mode 100644 index b80cca4..0000000 --- a/ArmstrongNumber +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -main() -{ - int n,t,r,s=0; - printf("Enter your choice:"); - scanf("%d",&n); - t=n; - int c=0,x; - x=n; - while(x>0) - { - r=x%10; - c=c+1; - x=x/10; - } - while(n>0) - { - r=n%10; - s=s+pow(r,c); - n=n/10; - } - if(s==t) - printf("%d is Armstrong",t); - else - printf("%d is not Armstrong!!!",t); -} diff --git a/BubbleSort.c b/BubbleSort.c deleted file mode 100644 index bc213ff..0000000 --- a/BubbleSort.c +++ /dev/null @@ -1,45 +0,0 @@ -#include - -//Bubble Sort -/* -* In Bubble sort, Each element of the array is compared with its adjacent element. - The algorithm processes the list in passes. - A list with n elements requires n-1 passes for sorting. - Consider an array A of n elements whose elements are to be sorted by using Bubble sort. - The algorithm processes like following. - In Pass 1, A[0] is compared with A[1], A[1] is compared with A[2], A[2] is compared with A[3] and so on. - At the end of pass 1, the largest element of the list is placed at the highest index of the list. - In Pass 2, A[0] is compared with A[1], A[1] is compared with A[2] and so on. - At the end of Pass 2 the second largest element of the list is placed at the second highest index of the list. - In pass n-1, A[0] is compared with A[1], A[1] is compared with A[2] and so on. At the end of this pass. - The smallest element of the list is placed at the first index of the list. - */ -void main(){ - - int i, j, temp; - printf("Enter the number of elements of the array"); - int n; - scanf("%d",&n); - int arr[n]; - printf("Enter the array: "); - for(i = 0; i < n ; i++) - { - scanf("%d",&arr[i]); - } - - - for(i = 0; i < n; i++){ - for(j = i+1; j < n-i-1 ; j++){ - if(arr[j] > a[j+1]){ - temp = arr[j]; - arr[j] = arr[j+1]; - arr[j+1] = temp; - } - } - } - - printf("The Sorted Elements are\t"); - for(int k =0; k -int main() -{ - int a, b; - char op; - int result; - printf("Enter First Number:"); - scanf("%d", &a); - printf("Enter Second Number:"); - scanf("%d", &b); - printf("Enter Operator of the Operation you want to perform :"); - scanf(" %c", &op); - switch (op) - { - case '+': - result=a+b; - printf("The Sum Is %d", result); - break; - case '-': - result=a-b; - printf("The Subtract Is %d", result); - break; - case '*': - result=a*b; - printf("The Multiply Is %d", result); - break; - case '/': - result=a/b; - printf("The Division Is %d", result); - break; - default: - printf("Please Enter a valid Operator"); - break; - } - return 0; -} diff --git a/DMA.c b/DMA.c deleted file mode 100644 index 601b3f0..0000000 --- a/DMA.c +++ /dev/null @@ -1,32 +0,0 @@ -/*This program shows the use of - *very basic functions of Dynamic memory - *allocation in C. - */ -#include -#include -int linearsearch(int *a,int n,int key) -{ - int i=0; - for(int i=0;i -int main() -{ -int n,sumeven=0,sumodd=0; -printf("Enter The Numbers of Elements :"); -scanf(" %d", &n); -printf("\n Enter %d The Numbers : ",n); -int a[n]; -for(int i=0;i -#include -#include -int main() -{ - char hex[17]; // declaration of character array. - long long decimal, place; - int i = 0, val, len; // variables declaration - decimal = 0; - /* Input hexadecimal number from user */ - printf("Enter any hexadecimal number: "); - gets(hex); -/* Find the length of total number of hex digit */ - len = strlen(hex); - len--; - - /* - * Iterate over each hex digit - */ - while(hex[i]!='\0') - { - - /* To find the decimal representation of hex[i] */ - if(hex[i]>='0' && hex[i]<='9') - { - val = hex[i] - 48; - } - else if(hex[i]>='a' && hex[i]<='f') - { - val = hex[i] - 97 + 10; - } - else if(hex[i]>='A' && hex[i]<='F') - { - val = hex[i] - 65 + 10; - } - - decimal += val * pow(16, len); diff --git a/InsertionSort.c b/InsertionSort.c deleted file mode 100644 index 02bf72b..0000000 --- a/InsertionSort.c +++ /dev/null @@ -1,29 +0,0 @@ -#include - -//Insertion Sort - /* - * Insertion sort is the simple sorting algorithm which is commonly used in the daily lives - * while ordering a deck of cards. - In this algorithm, we insert each element onto its proper place in the sorted array. - This is less efficient than the other sort algorithms like quick sort, merge sort, etc. - */ -void main(){ - - int i, j, k, temp; - int a[10] = { 56, 34, 76, 23, 73, 213, 766, 34, 77, 12 }; - - printf("Printing sorted elements\t"); - for(k = 1; k<10; k++){ - temp = a[k]; - j = k-1; - while(j>=0 && temp <=a[j]){ - a[j+1] = a[j]; - j = j-1; - } - a[j+1] = temp; - } - for(i = 0; i<10; i++){ - printf("%d\t" , a[i]); - } - -} diff --git a/Insertion_sort.c b/Insertion_sort.c deleted file mode 100644 index f08d8ba..0000000 --- a/Insertion_sort.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -/* Function to sort an array using insertion sort*/ -void insertionSort(int arr[], int n) -{ - int i, key, j; - for (i = 1; i < n; i++) { - key = arr[i]; - j = i - 1; - - /* Move elements of arr[0..i-1], that are - greater than key, to one position ahead - of their current position */ - while (j >= 0 && arr[j] > key) { - arr[j + 1] = arr[j]; - j = j - 1; - } - arr[j + 1] = key; - } -} - -// A utility function to print an array of size n -void printArray(int arr[], int n) -{ - int i; - for (i = 0; i < n; i++) - printf("%d ", arr[i]); - printf("\n"); -} - -/* Driver program to test insertion sort */ -int main() -{ - int arr[] = { 12, 11, 13, 5, 6 }; - int n = sizeof(arr) / sizeof(arr[0]); - - insertionSort(arr, n); - printArray(arr, n); - - return 0; -} \ No newline at end of file diff --git a/LCF b/LCF deleted file mode 100644 index 56f84e1..0000000 --- a/LCF +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -void main() -{ - int a,b,m,i=1; - printf("Enter the Two numbers"); - scanf("%d",&a); - scanf("%d",&b); - m=a; - while(m%b!=0) - { - i++; - m=a*i; - } - printf("%d",m); -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f288702..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/LL(Insertion At Begining).c b/LL(Insertion At Begining).c deleted file mode 100644 index ea90a37..0000000 --- a/LL(Insertion At Begining).c +++ /dev/null @@ -1,57 +0,0 @@ -#include -/* At first we have to create a stucture Named Node(you can name anything), with one integer variable data and -pointer to structre variable varible next(which will be useful to us while back tracing the list). when we enter a -new data to the list this next(pointer to struct) varible will work as link to the starting elements. -*/ -struct Node{ - int data; - struct Node* next; -}; -/* Then we will a declare a pointer to structure varible head which will have global scope(This global pointer to -structure varible will also help us to keep a record of previous link(Address)) ---GOTO_MAIN_FUNCTION_COMMENTS--*/ -struct Node* head; -/* To enter data to the linked list we are using Insert function(following algorithm). -In the begining we will declare a pointer to structure(Node) temp, and allocate it memory of size of structure Node -(which is usually 16 bytes). -Now assign user enter value(x) to the data varible of structure Node and assign value of head(which is an address) -to the pointer to the structure varible next(which is NULL at the time of initial compilation), then assign the -address of temp varible to the head(which will be usefull for next iteraion). -*/ -void Insert(int x){ - struct Node* temp = (struct Node*)malloc(sizeof(struct Node)); - temp->data = x; - temp->next = head; - head = temp; -} -/* First assign the address in the head to the temp variable(to access that variable), then just print data from -that structure, then assign the temp->next to the temp varible. -*/ -void Print(){ - struct Node* temp = head; - printf("The List is "); - while(temp!=NULL){ - - printf(" %d", temp->data); - temp=temp->next; - } - printf("\n"); - -} -/* At first we will set global pointer to structure variable head to NULL(0) to keep a record of first element. -then we will collect the required values from user such as length of the list, data to be entered to the list. -thenafter we will call our Insert() and Print() function. -*/ -int main(){ - head = NULL; - int x, i, n; - puts("How many Nos you want to enter to the list:"); - scanf("%d", &n); - for(i = 0; i - -//Binary Search Alogorithm - -/* - Binary search is the search technique which works efficiently on the *sorted* lists. - Hence, in order to search an element into some list by using binary search technique, - we must ensure that the list is sorted. - Binary search follows divide and conquer approach in which, - the list is divided into two halves and the item is compared with the middle element of the list. - If the match is found then, the location of middle element is returned otherwise, - we search into either of the halves depending upon the result produced through the match. - */ - -int binarySearch( int a[] , int beg , int end , int item){ //beg =10 end =9 item 430 - - int mid; - if( end >= beg){ - mid = (beg + end)/2; - if(a[mid] == item){ - return mid + 1; - }else if(a[mid] < item){ - return binarySearch( a , mid +1, end , item); - }else{ - return binarySearch( a , beg , mid-1 , item); - } - } - return 0; - -} - -int main(){ - - int array[10] = { 2, 3, 43, 66, 76, 77, 90, 101, 122, 125 }; - int item , location = 0; - puts("Enter number you want to search:"); - scanf("%d" , &item); - location = binarySearch( array , 0 , 9 , item); - - if(location != 0){ - printf("Item found at postion : %d" , location ); - } - else{ - printf("item not found"); - } - -return 0; -} diff --git a/LinerSearchAlgo.c b/LinerSearchAlgo.c deleted file mode 100644 index 94dc848..0000000 --- a/LinerSearchAlgo.c +++ /dev/null @@ -1,41 +0,0 @@ -#include - -//Liner Search Algorithm. -/* - * Linear search is the simplest search algorithm and often called sequential search. - * In this type of searching, we simply traverse the list completely and match each element of - * the list with the item whose location is to be found. If the match found then location of - * the item is returned otherwise the algorithm return NULL. - Linear search is mostly used to search an unordered list in which the items are not sorted. - The algorithm of linear search is given as follows. - */ - - -int main(){ - - int array[10] = { 2, 34, 56, 23, 65, 21, 67, 99, 45, 62 }; - int flag, item, i; - - printf("Enter Item which you want to search\n"); - scanf("%d" , &item); - - for(int i = 0 ; i < 10 ; i++){ - if( array[i] == item){ - flag = i+1; - break; - } - else{ - flag=0; - } - } - if(flag!=0){ - printf("Item found at postion %d\n" , flag); - } - else{ - printf("\nItem Not Found\n"); - - } - - -return 0; -} diff --git a/Linked List b/Linked List deleted file mode 100644 index ac1f35f..0000000 --- a/Linked List +++ /dev/null @@ -1,133 +0,0 @@ -#include -#include -struct node -{ - int data; - struct node *next ; - -}*head,*tail; -/* Code for insertion at the beginning*/ -void insert_at_beg () -{ - struct node *newnode ; - newnode= (struct node*)malloc(sizeof(struct node)); - printf("Enter Data "); - scanf("%d",&(*newnode).data); - newnode->next=head; - head=newnode; - -} -/* Code for insertion at end*/ -void insert_at_end() -{ - struct node *newnode ; - newnode= (struct node*)malloc(sizeof(struct node)); - printf("Enter Data "); - scanf("%d",&(*newnode).data); - newnode->next=tail->next; - tail->next=newnode; - tail=newnode; - -} - -/* Code for insertion at ant specific position */ -void insert_at_pos() -{ - int pos; - int count; - printf("Enter the position"); - scanf("%d",&pos); - int i=1; - struct node *temp; - temp=head; - if (inext; - } - struct node *newnode ; - newnode= (struct node*)malloc(sizeof(struct node)); - printf("Enter Data "); - scanf("%d",&(*newnode).data); - newnode->next=temp->next; - temp->next=newnode; - -} - - - - /* Code for Displaying Elements*/ -void display() -{ - tail= head; - while(tail->next=head); - { - printf("%d",tail->data); - printf("\n"); - tail=tail->next; - } - printf("%d",tail->data); -} - -int main () -{ - - head=0; - int dec =1; - int count =0; - while(dec) - { - /* Creating node*/ - struct node *newnode ; - newnode= (struct node*)malloc(sizeof(struct node)); - printf("Enter Data "); - scanf("%d",&(*newnode).data); - newnode->next=0; - count++; - if(head==0) - { - head=newnode; - tail=newnode; - } - else - { - tail->next=newnode; - tail=newnode; - - } - printf("Do you want to continue(0,1)?"); - scanf("%d",&dec); - newnode->next=head; - - } - do - { - int choice; - int flag =0; - printf("Enter the Choice \n"); - printf("Enter 1 to insert at beginning \n"); - printf("Enter 2 to insert at end\n"); - printf("Enter 3 to insert at specific position\n"); - printf("Enter 4 to display element\n"); - scanf("%d",&choice); - switch(choice) - { - case 1:insert_at_beg(); - break; - case 2:insert_at_end(); - break; - case 3: printf("Postion should be less than %d",count); - printf("\n"); - insert_at_pos(); - break; - case 4:display(); - break; - default: - flag=1; - break; - if (flag ==0) - continue; - if(flag==1) - break; - } - }while(1); - } diff --git a/Merge Sort in C. b/Merge Sort in C. deleted file mode 100644 index a1330b1..0000000 --- a/Merge Sort in C. +++ /dev/null @@ -1,140 +0,0 @@ -/* C program for Merge Sort */ -#include -#include -main() -{ - int i,j,k,n,temp; - int arr[100]; - printf("How many numbers are u going to enter?: "); - scanf("%d",&n); - - printf("Enter %d numbers: ",n); - - for(i=0;iarr[j+1]) - { - temp=arr[j]; - arr[j]=arr[j+1]; - arr[j+1]=temp; - } - } - } - printf("Sorted elements: "); - for(i=0;i -#include - -// Merges two subarrays of arr[]. -// First subarray is arr[l..m] -// Second subarray is arr[m+1..r] -void merge(int arr[], int l, int m, int r) -{ - int i, j, k; - int n1 = m - l + 1; - int n2 = r - m; - - /* create temp arrays */ - int L[n1], R[n2]; - - /* Copy data to temp arrays L[] and R[] */ - for (i = 0; i < n1; i++) - L[i] = arr[l + i]; - for (j = 0; j < n2; j++) - R[j] = arr[m + 1+ j]; - - /* Merge the temp arrays back into arr[l..r]*/ - i = 0; // Initial index of first subarray - j = 0; // Initial index of second subarray - k = l; // Initial index of merged subarray - while (i < n1 && j < n2) - { - if (L[i] <= R[j]) - { - arr[k] = L[i]; - i++; - } - else - { - arr[k] = R[j]; - j++; - } - k++; - } - - /* Copy the remaining elements of L[], if there - are any */ - while (i < n1) - { - arr[k] = L[i]; - i++; - k++; - } - - /* Copy the remaining elements of R[], if there - are any */ - while (j < n2) - { - arr[k] = R[j]; - j++; - k++; - } -} - -/* l is for left index and r is right index of the -sub-array of arr to be sorted */ -void mergeSort(int arr[], int l, int r) -{ - if (l < r) - { - // Same as (l+r)/2, but avoids overflow for - // large l and h - int m = l+(r-l)/2; - - // Sort first and second halves - mergeSort(arr, l, m); - mergeSort(arr, m+1, r); - - merge(arr, l, m, r); - } -} - -/* UTILITY FUNCTIONS */ -/* Function to print an array */ -void printArray(int A[], int size) -{ - int i; - for (i=0; i < size; i++) - printf("%d ", A[i]); - printf("\n"); -} - -/* Driver program to test above functions */ -int main() -{ - int arr[] = {12, 11, 13, 5, 6, 7}; - int arr_size = sizeof(arr)/sizeof(arr[0]); - - printf("Given array is \n"); - printArray(arr, arr_size); - - mergeSort(arr, 0, arr_size - 1); - - printf("\nSorted array is \n"); - printArray(arr, arr_size); - return 0; -} diff --git a/README.md b/README.md deleted file mode 100644 index 2b23a10..0000000 --- a/README.md +++ /dev/null @@ -1,11 +0,0 @@ -C-Programming - - This repository very clearly laid out c programming, and briefly mentions all major projects and programs for beginners, as well as provide them simple and easy to learn c programs - -Happy Coding!! - -Thank you!! - -A star will be appreciated - - diff --git a/RECRSION b/RECRSION deleted file mode 100644 index 85bdd7e..0000000 --- a/RECRSION +++ /dev/null @@ -1,25 +0,0 @@ -#include -int fact (int); -int main() -{ - int n,f; - printf("Enter the number whose factorial you want to calculate?"); - scanf("%d",&n); - f = fact(n); - printf("factorial of %d is %d",n,f); -} -int fact(int n) -{ - if (n==0) - { - return 0; - } - else if ( n == 1) - { - return 1; - } - else - { - return n*fact(n-1); - } -} diff --git a/RECURSION b/RECURSION deleted file mode 100644 index 6e28dc4..0000000 --- a/RECURSION +++ /dev/null @@ -1,25 +0,0 @@ -#include -int fact (int); -int main() -{ - int n,f; - printf("Enter the number whose factorial you want to calculate?"); - scanf("%d",&n); - f = fact(n); - printf("factorial = %d",f); -} -int fact(int n) -{ - if (n==0) - { - return 0; - } - else if ( n == 1) - { - return 1; - } - else - { - return n*fact(n-1); - } -} diff --git a/Sparse Matrix b/Sparse Matrix deleted file mode 100644 index db464a9..0000000 --- a/Sparse Matrix +++ /dev/null @@ -1,68 +0,0 @@ -#include -#define MAX 20 -#include -void read_matrix(int a[10][10], int row, int column); -void print_sparse(int b[MAX][3]); -void create_sparse(int a[10][10], int row, int column, int b[MAX][3]); - -int main() -{ - int a[10][10], b[MAX][3], row, column; - printf("\nEnter the size of matrix (rows, columns): "); - scanf("%d%d", &row, &column); - - read_matrix(a, row, column); - create_sparse(a, row, column, b); - print_sparse(b); getch(); - return 0; -} - -void read_matrix(int a[10][10], int row, int column) -{ - int i, j; - printf("\nEnter elements of matrix\n"); - for (i = 0; i < row; i++) - { - for (j = 0; j < column; j++) - { - printf("[%d][%d]: ", i, j); - scanf("%d", &a[i][j]); - } - } -} - -void create_sparse(int a[10][10], int row, int column, int b[MAX][3]) -{ - int i, j, k; - k = 1; - b[0][0] = row; - b[0][1] = column; - for (i = 0; i < row; i++) - { - for (j = 0; j < column; j++) - { - if (a[i][j] != 0) - { - b[k][0] = i; - b[k][1] = j; - b[k][2] = a[i][j]; - k++; - } - } - b[0][2] = k - 1; - } -} - -void print_sparse(int b[MAX][3]) -{ - int i, column; - column = b[0][2]; - printf("\nSparse form - list of 3 triples\n\n"); - for (i = 0; i <= column; i++) - { - printf("%d\t%d\t%d\n", b[i][0], b[i][1], b[i][2]); - } - printf("\n"); - - return 0; -} diff --git a/Stack.c b/Stack.c deleted file mode 100644 index f43013d..0000000 --- a/Stack.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -int stack[100],choice,n,top,x,i; -void push(void); -void pop(void); -void display(void); -int main() -{ - //clrscr(); - 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: - { - printf("\n\t EXIT POINT "); - break; - } - default: - { - printf ("\n\t Please Enter a Valid Choice(1/2/3/4)"); - } - - } - } - while(choice!=4); - return 0; -} -void push() -{ - if(top>=n-1) - { - printf("\n\tSTACK is over flow"); - - } - else - { - printf(" Enter a value to be pushed:"); - scanf("%d",&x); - top++; - stack[top]=x; - } -} -void pop() -{ - if(top<=-1) - { - printf("\n\t Stack is under flow"); - } - else - { - printf("\n\t The popped elements is %d",stack[top]); - top--; - } -} -void display() -{ - if(top>=0) - { - printf("\n The elements in STACK \n"); - for(i=top; i>=0; i--) - printf("\n%d",stack[i]); - printf("\n Press Next Choice"); - } - else - { - printf("\n The STACK is empty"); - } - -} diff --git a/Sum_Diagnols.c b/Sum_Diagnols.c deleted file mode 100644 index 5bfaa99..0000000 --- a/Sum_Diagnols.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -int main(){ - int row, sum = 0; - printf("Input the rows and columns of a matrix: "); - scanf("%d", &row); - - int **array = malloc(row * sizeof(int)); - for (int i = 0; i < row; ++i){ - array[i] = (int *)malloc(row * sizeof(int)); - } - - printf("\nInput the elements of the matrix:"); - - for (int i = 0; i < row; ++i){ - for (int j = 0; j < row; ++j){ - printf("\nelement - [%d] [%d]: ", i, j); - scanf("%d", &array[i][j]); - } - } - - printf("\nThe matrix is:\n"); - for (int i = 0; i < row; ++i){ - for (int j = 0; j < row; ++j){ - printf("%d\t", array[i][j]); - } - printf("\n"); - } - - for (int i = 0; i < row; ++i){ - for (int j = 0; j < row; ++j){ - if (i == j){ - sum = sum + array[i][j]; - } - } - } - printf("Addition of the diagnol elements is: %d\n", sum); - free(array); -} \ No newline at end of file diff --git a/TRANSPOSE_0FMATRIX.c b/TRANSPOSE_0FMATRIX.c deleted file mode 100644 index b85d6d6..0000000 --- a/TRANSPOSE_0FMATRIX.c +++ /dev/null @@ -1,28 +0,0 @@ -#include - -int main() -{ - int m, n, c, d, matrix[10][10], transpose[10][10]; - - printf("Enter the number of rows and columns of a matrix\n"); - scanf("%d%d", &m, &n); - printf("Enter elements of the matrix\n"); - - for (c = 0; c < m; c++) - for (d = 0; d < n; d++) - scanf("%d", &matrix[c][d]); - - for (c = 0; c < m; c++) - for (d = 0; d < n; d++) - transpose[d][c] = matrix[c][d]; - - printf("Transpose of the matrix:\n"); - - for (c = 0; c < n; c++) { - for (d = 0; d < m; d++) - printf("%d\t", transpose[c][d]); - printf("\n"); - } - - return 0; -} diff --git a/Take input from user b/Take input from user deleted file mode 100644 index 14f1e9e..0000000 --- a/Take input from user +++ /dev/null @@ -1,25 +0,0 @@ -#include -int main() -{ - int no1, no2; - int sum, sub, mult, mod; - float div; - - printf("Enter any two numbers separated it by comma : "); - scanf("%d,%d", &no1, &no2); - - // Performs all arithmetic operations - sum = no1 + no2; - sub = no - no2; - mult = no1 * no2; - div = (float)no1 / no2; - mod = no1 % no2; - - // Prints the result of all arithmetic operations - printf("The sum of the entered numbers : %d\n", sum); - printf("The difference of the entered numbers : %d\n", sub); - printf("The product of the entered numbers : %d\n", mult); - printf("The quotient of the entered numbers : %f\n", div); - printf("Mod = %d\n", mod); //remainder - -} diff --git a/TicTacToe.c b/TicTacToe.c deleted file mode 100644 index 0265a2d..0000000 --- a/TicTacToe.c +++ /dev/null @@ -1,228 +0,0 @@ -#include -#include - -#if defined(_WIN32) || defined(_WIN64) - #define WINDOWS - #include - -#elif defined(unix) - #define UNIX - char getch(void); -#else - #error "Platform is not supported" -#endif - -void clear (void) { - #ifdef WINDOWS - printf("\033[2J"); - printf("\033[0;0f"); - #else - system("clear"); - #endif -} - -#ifdef UNIX - char getch (void) { - char ch; - system("stty raw"); - ch = getchar(); - system("stty cooked"); - return ch; - } -#endif - -enum {Y = 7, X = 13}; -typedef enum {false, true} bool; - -enum State { ZERO = 'O', CROSS = 'X' }; -static enum State now = CROSS; - -static char map[Y][X] = { - "=============", - "| 7 | 8 | 9 |", - "=============", - "| 4 | 5 | 6 |", - "=============", - "| 1 | 2 | 3 |", - "=============" -}; - -#define NUM1 map[5][2] -#define NUM2 map[5][6] -#define NUM3 map[5][10] -#define NUM4 map[3][2] -#define NUM5 map[3][6] -#define NUM6 map[3][10] -#define NUM7 map[1][2] -#define NUM8 map[1][6] -#define NUM9 map[1][10] - -#define CHANGE(x) (x = now) -#define GOTO(x) if(x == ZERO || x == CROSS) goto again; else CHANGE(x); - -static void menu (void); -static void game (void); - -static void printMap (void); -static bool checkWin (void); - -static void restart (void); - -int main (void) { - menu(); - return 0; -} - -static void menu (void) { - auto char symbol; - start: - clear(); - - printf("\v\tPRESS '1' TO START GAME\n"); - printf("\tPRESS '0' TO STOP GAME\n"); - printf("\t> "); - - restart: - symbol = getch(); - - switch(symbol) { - case '1': game(); break; - case '0': printf("\n\n"); return; - default: goto start; - } - - restart(); - - printf("\v\tPRESS '1' TO PLAY AGAIN\n"); - printf("\tPRESS '0' TO STOP GAME\n"); - printf("\t> "); - - goto restart; -} - -static void restart (void) { - now = CROSS; - NUM7 = '7'; NUM8 = '8'; NUM9 = '9'; - NUM4 = '4'; NUM5 = '5'; NUM6 = '6'; - NUM1 = '1'; NUM2 = '2'; NUM3 = '3'; -} - -static void game (void) { - auto char symbol; - while(true) { - again: - printMap(); - printf("\v\t Number > "); - - symbol = getch(); - - switch(symbol) { - case '0': printf("\n\n"); return; - case '1': GOTO(NUM1); break; - case '2': GOTO(NUM2); break; - case '3': GOTO(NUM3); break; - case '4': GOTO(NUM4); break; - case '5': GOTO(NUM5); break; - case '6': GOTO(NUM6); break; - case '7': GOTO(NUM7); break; - case '8': GOTO(NUM8); break; - case '9': GOTO(NUM9); break; - default: goto again; - } - - if (checkWin()) return; - - if (now == CROSS) now = ZERO; - else now = CROSS; - } -} - -static void printMap (void) { - auto unsigned char x, y; - - clear(); printf("\n\v"); - - for (y = 0; y < 7; y++) { - printf("\t"); - for (x = 0; x < 13; x++) - printf("%c", map[y][x]); - printf("\n"); - } -} - -static bool checkWin (void) { - auto bool win = false; - auto char temp; - - /* HORIZONTAL */ - - if ((NUM7 == ZERO && NUM8 == ZERO && NUM9 == ZERO)|| - (NUM7 == CROSS && NUM8 == CROSS && NUM9 == CROSS) - ) { - temp = NUM7; NUM7 = NUM8 = NUM9 = '-'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - if ((NUM4 == ZERO && NUM5 == ZERO && NUM6 == ZERO)|| - (NUM4 == CROSS && NUM5 == CROSS && NUM6 == CROSS) - ) { - temp = NUM4; NUM4 = NUM5 = NUM6 = '-'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - if ((NUM1 == ZERO && NUM2 == ZERO && NUM3 == ZERO)|| - (NUM1 == CROSS && NUM2 == CROSS && NUM3 == CROSS) - ) { - temp = NUM1; NUM1 = NUM2 = NUM3 = '-'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - /* VERTICAL */ - - if ((NUM7 == ZERO && NUM4 == ZERO && NUM1 == ZERO)|| - (NUM7 == CROSS && NUM4 == CROSS && NUM1 == CROSS) - ) { - temp = NUM7; NUM7 = NUM4 = NUM1 = '|'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - if ((NUM8 == ZERO && NUM5 == ZERO && NUM2 == ZERO)|| - (NUM8 == CROSS && NUM5 == CROSS && NUM2 == CROSS) - ) { - temp = NUM8; NUM8 = NUM5 = NUM2 = '|'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - if ((NUM9 == ZERO && NUM6 == ZERO && NUM3 == ZERO)|| - (NUM9 == CROSS && NUM6 == CROSS && NUM3 == CROSS) - ) { - temp = NUM9; NUM9 = NUM6 = NUM3 = '|'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - /* DIAGONAL */ - - if ((NUM7 == ZERO && NUM5 == ZERO && NUM3 == ZERO)|| - (NUM7 == CROSS && NUM5 == CROSS && NUM3 == CROSS) - ) { - temp = NUM7; NUM7 = NUM5 = NUM3 = '\\'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - if ((NUM9 == ZERO && NUM5 == ZERO && NUM1 == ZERO)|| - (NUM9 == CROSS && NUM5 == CROSS && NUM1 == CROSS) - ) { - temp = NUM9; NUM9 = NUM5 = NUM1 = '/'; printMap(); - printf("\n\t WIN: %s\n\n",(temp == ZERO)?" ZERO":" CROSS"); - win = true; - } - - return win; -} diff --git a/Vowel or not b/Vowel or not deleted file mode 100644 index d43301d..0000000 --- a/Vowel or not +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -main() -{ - char c; - scanf("%c",&c); - printf("Entered Character is :%c\n",c); - if(((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'))) - { - switch(c) - { - - - case 'a': - case 'e': - case 'i': - case 'o': - case 'u': - case 'A': - case 'E': - case 'I': - case 'O': - case 'U': - printf("Entered character %c is vowel.",c); - break; - default: - printf("Entered character %c is not vowel",c); - } - - } - else - printf("Entered character %c is not valid character",c); - - -} diff --git a/add.c b/add.c deleted file mode 100644 index b99556b..0000000 --- a/add.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -int main() //main function -{ - int a,b; - - printf("Enter first number:\n"); - scanf ("%d",&a); - printf("Enter second number:\n"); - scanf ("%d",&b); - - printf("Addition of two numbers = %d",a+b); - return 0; -} diff --git a/additionarray.c b/additionarray.c deleted file mode 100644 index 5ce2ad1..0000000 --- a/additionarray.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int main() -{ - int arr1[5],arr2[5],arr3[5],i; - printf("Enter 5 numbers of arr1:"); - for(i=0;i<=4;i++) - { - scanf("%d",&arr1[i]);//Taking input from the user for the first array. - } - printf("Enter 5 numbers of arr2:"); - for(i=0;i<=4;i++) - { - scanf("%d",&arr2[i]);//Taking input from the user for the second array. - } - for(i=0;i<=4;i++) - { - arr3[i]=arr1[i]+arr2[i];//Addition of the two arrays. - } - printf("Addition of two array:"); - for(i=0;i<=4;i++) - { - printf("%d\t",arr3[i]);//Printing the new array. - } -} diff --git a/armstrong.c b/armstrong.c deleted file mode 100644 index 141780d..0000000 --- a/armstrong.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int main() { - int num, originalNum, remainder, result = 0; - printf("Enter a three-digit integer: "); - scanf("%d", &num); - originalNum = num; - - while (originalNum != 0) { - // remainder contains the last digit - remainder = originalNum % 10; - - result += remainder * remainder * remainder; - - // removing last digit from the orignal number - originalNum /= 10; - } - - if (result == num) - printf("%d is an Armstrong number.", num); - else - printf("%d is not an Armstrong number.", num); - - return 0; -} diff --git a/armstrong_number.cpp b/armstrong_number.cpp deleted file mode 100644 index 8fd1c6f..0000000 --- a/armstrong_number.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//C program to check if a number is armstrong number or not using functions. - -#include - -int isArmstrong(int number) -{ - - // declare variables - int lastDigit = 0; - int power = 0; - int sum = 0; - - // temporary variable to store number - int n = number; - - while(n!=0) { - - // find last digit - lastDigit = n % 10; - - // find power of digit (order = 3) - power = lastDigit*lastDigit*lastDigit; - - // add power value into sum - sum += power; - - // remove last digit - n /= 10; - } - - if(sum == number) return 0; - else return 1; -} - -int main() -{ - int number; - - printf("Enter number: "); - scanf("%d",&number); - - if(isArmstrong(number) == 0) - printf("%d is an Armstrong number.\n", number); - else - printf("%d is not an Armstrong number.", number); - - return 0; -} diff --git a/armstronginrange.c b/armstronginrange.c deleted file mode 100644 index 3e65b49..0000000 --- a/armstronginrange.c +++ /dev/null @@ -1,26 +0,0 @@ -/*C program to display armstrong number -between 1 to 1000*/ - -#include -int main() -{ - int num,temp,result,rem; - printf("Armstrong number between 1 to 1000:\n"); - for(num=1;num<=1000;num++) - { - temp=0; - result=0; - while(temp>0) - { - rem=temp%10; - result+=rem*rem*rem; - temp=temp/10; - - } - if(num==result) - { - printf("%d\n",num); - } - } - return 0; -} diff --git a/array10number.c b/array10number.c deleted file mode 100644 index 49822ba..0000000 --- a/array10number.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to input 10 numbers from user and display 10 numbers using array. - -#include -int main() -{ - int a[10],i; - printf("Enter 10 numbers:"); - - for(i=0;i<=9;i++) - { - scanf("%d",&a[i]); - } - for(i=0;i<=9;i++) - { - printf("%d\t",a[i]); - } -} diff --git a/average.c b/average.c deleted file mode 100644 index 984377c..0000000 --- a/average.c +++ /dev/null @@ -1,13 +0,0 @@ -//C program to find average of 5 numbers. - -#include -int main() -{ - float n1,n2,n3,n4,n5; - float avg; - printf("Enter five numbers:"); - scanf("%f%f%f%f%f",&n1,&n2,&n3,&n4,&n5); - avg=(n1+n2+n3+n4+n5)/(5.0); - printf("Average of five numbers=%lf",avg); - return 0; -} diff --git a/averagealt.c b/averagealt.c deleted file mode 100644 index dc502fa..0000000 --- a/averagealt.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -int main() -{ - int s,i,sum=0; - float avg; - printf("Enter five numbers:"); - scanf("%d",&s); - for(i=1;i<=5;i++) - { - sum=sum+s; - } - avg=(sum/5.0); - printf("Average of numbers=%f",avg); - return 0; -} diff --git a/binary_insertion_sort.cpp b/binary_insertion_sort.cpp deleted file mode 100644 index bc1d4e3..0000000 --- a/binary_insertion_sort.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -template -/* A function to print values inside a vector */ -std::ostream& operator<<(std::ostream& out, std::vector& ls) -{ - out<<'['; - - for(auto i = ls.begin(); i != ls.end(); ++i) - out<<*i<<(i + 1 == ls.end() ? "" : ", "); - - out<<']'; - - return out; -} - -template -/* The main insertion sort function */ -void binary_insertion_sort(Container& ctx) -{ - for(auto a = ctx.begin(); a != ctx.end(); ++a) - std::rotate( - std::upper_bound(ctx.begin(), a, *a), - //determines the maximum element in the range - a, - a + 1 - ); //pushes the element to the last - -} - -int main() -{ - std::vector vec = {90, 1, 20, 45, 0, 18, 3}; - std::cout<<"The vector before sorting "< -#include -#include -#include -#include - -#define ROWS 10 -#define LENGTH 50 -void descending(char [ROWS][LENGTH]); -void ascending(char [ROWS][LENGTH]); -void display(void); - -int main(){ - int start, end, mid, t1, t2; - char s[ROWS][LENGTH]; - char s2[ROWS][LENGTH]; - char search_name[LENGTH]; - char found = 'F'; - int i = 0; - start = 0; - end = ROWS; - do{ - printf("Enter name: "); - scanf("%s", s[i]); - strcpy(s2[i], s[i]); - if (s[i][0] >= 65 && s[i][0] <= 90){ - s[i][0] = (int)s[i][0] + 32; - } - ++i; - }while(i < ROWS); - - char temp[50]; - char swap = 'Y'; - while (swap == 'Y'){ - swap = 'N'; - for (int i = 0; i < (ROWS - 1); ++i){ - if (strcmp(s[i], s[i+1]) > 0){ - swap = 'Y'; - strcpy(temp, s[i]); - strcpy(s[i], s[i+1]); - strcpy(s[i+1], temp); - } - } - } - printf("\n"); - for(int i = 0; i < ROWS; ++i){ - printf("%s\n", s[i]); - } - - printf("\nEnter name to search: "); - scanf("%s", search_name); - - t1 = clock(); - while(start <= end && found == 'F'){ - mid = (start + end) / 2; - if (strcmp(search_name, s[mid]) == 0){ - found = 'T'; - } - else{ - if (strcmp(search_name, s[mid]) > 0){ - start = mid + 1; - } - else { - end = mid - 1; - } - } - if (found == 'T'){ - printf("Found name at: %d\n", mid); - } - } - t2 = clock(); - double time_taken = (double)(t2 - t1) / CLOCKS_PER_SEC; - printf("\n\nTime taken: %f", time_taken); -} \ No newline at end of file diff --git a/bst_program.c b/bst_program.c new file mode 100644 index 0000000..77ab0b1 --- /dev/null +++ b/bst_program.c @@ -0,0 +1,246 @@ +#include +#include + +struct node { + int data; + struct node *lchild; + struct node *rchild; +}; + +typedef struct node node; +node *root = NULL; + +// Create BST nodes +void create() { + int x, ch; + node *t, *temp, *parent; + do { + t = (node*)malloc(sizeof(node)); + t->lchild = t->rchild = NULL; + printf("Enter data: "); + scanf("%d", &x); + t->data = x; + + if (root == NULL) { + root = t; + } else { + temp = root; + while (temp != NULL) { + parent = temp; + if (x < temp->data) + temp = temp->lchild; + else + temp = temp->rchild; + } + if (x < parent->data) + parent->lchild = t; + else + parent->rchild = t; + } + + printf("To create another node, press 1 (or 0 to stop): "); + scanf("%d", &ch); + } while (ch != 0); +} + +// Traversals +void preorder(node *t) { + if (t != NULL) { + printf("%d ", t->data); + preorder(t->lchild); + preorder(t->rchild); + } +} + +void inorder(node *t) { + if (t != NULL) { + inorder(t->lchild); + printf("%d ", t->data); + inorder(t->rchild); + } +} + +void postorder(node *t) { + if (t != NULL) { + postorder(t->lchild); + postorder(t->rchild); + printf("%d ", t->data); + } +} + +void traversal() { + int ch; + do { + printf("\n1. Preorder\n2. Inorder\n3. Postorder\n4. Exit\nEnter your choice: "); + scanf("%d", &ch); + switch (ch) { + case 1: + printf("Preorder: "); + preorder(root); + printf("\n"); + break; + case 2: + printf("Inorder: "); + inorder(root); + printf("\n"); + break; + case 3: + printf("Postorder: "); + postorder(root); + printf("\n"); + break; + case 4: + return; + } + } while (1); +} + +// Count nodes +int count_nodes(node *t) { + if (!t) return 0; + return count_nodes(t->lchild) + count_nodes(t->rchild) + 1; +} + +int count_leaf_nodes(node *t) { + if (!t) return 0; + if (!t->lchild && !t->rchild) return 1; + return count_leaf_nodes(t->lchild) + count_leaf_nodes(t->rchild); +} + +int count_parent_nodes(node *t) { + if (!t) return 0; + if (t->lchild || t->rchild) + return 1 + count_parent_nodes(t->lchild) + count_parent_nodes(t->rchild); + return 0; +} + +// Height +int height(node *t) { + if (!t) return 0; + int hl = height(t->lchild); + int hr = height(t->rchild); + return (hl > hr ? hl : hr) + 1; +} + +// Balanced check for root +void balanced_nodes(node *t) { + int cl = count_nodes(t->lchild); + int cr = count_nodes(t->rchild); + if (cl == cr) + printf("Nodes are balanced at root\n"); + else if (cl > cr) + printf("Nodes are left imbalanced at root\n"); + else + printf("Nodes are right imbalanced at root\n"); +} + +void balanced_height(node *t) { + int hl = height(t->lchild); + int hr = height(t->rchild); + if (hl == hr) + printf("Height is balanced at root\n"); + else if (hl > hr) + printf("Height is left imbalanced at root\n"); + else + printf("Height is right imbalanced at root\n"); +} + +// Minimum & Maximum +node* find_min(node *t) { + while (t && t->lchild) t = t->lchild; + return t; +} + +node* find_max(node *t) { + while (t && t->rchild) t = t->rchild; + return t; +} + +// Delete node +node* delete_node(node *t, int key) { + if (!t) return NULL; + if (key < t->data) + t->lchild = delete_node(t->lchild, key); + else if (key > t->data) + t->rchild = delete_node(t->rchild, key); + else { + if (!t->lchild) { + node *temp = t->rchild; + free(t); + return temp; + } else if (!t->rchild) { + node *temp = t->lchild; + free(t); + return temp; + } else { + node *temp = find_min(t->rchild); + t->data = temp->data; + t->rchild = delete_node(t->rchild, temp->data); + } + } + return t; +} + +// Search +void search() { + node *temp = root; + int x; + printf("Enter data to search: "); + scanf("%d", &x); + while (temp) { + if (x == temp->data) { + printf("%d is found\n", x); + return; + } + temp = (x < temp->data) ? temp->lchild : temp->rchild; + } + printf("%d is not found\n", x); +} + +// Free memory +void free_tree(node *t) { + if (!t) return; + free_tree(t->lchild); + free_tree(t->rchild); + free(t); +} + +int main() { + int ch, key; + do { + printf("\n1.Create\n2.Traversal\n3.Count nodes\n4.Count leaf nodes\n5.Count parent nodes\n"); + printf("6.Height\n7.Balanced nodes\n8.Balanced height\n9.Minimum\n10.Maximum\n11.Delete node\n12.Search\n0.Exit\n"); + printf("Enter your choice: "); + scanf("%d", &ch); + switch(ch) { + case 1: create(); break; + case 2: traversal(); break; + case 3: printf("Number of nodes: %d\n", count_nodes(root)); break; + case 4: printf("Number of leaf nodes: %d\n", count_leaf_nodes(root)); break; + case 5: printf("Number of parent nodes: %d\n", count_parent_nodes(root)); break; + case 6: printf("Height: %d\n", height(root)); break; + case 7: balanced_nodes(root); break; + case 8: balanced_height(root); break; + case 9: { + node *minNode = find_min(root); + if(minNode) printf("Minimum: %d\n", minNode->data); + break; + } + case 10: { + node *maxNode = find_max(root); + if(maxNode) printf("Maximum: %d\n", maxNode->data); + break; + } + case 11: + printf("Enter node to delete: "); + scanf("%d", &key); + root = delete_node(root, key); + printf("%d deleted (if it existed)\n", key); + break; + case 12: search(); break; + case 0: free_tree(root); exit(0); + } + } while(1); + + return 0; +} \ No newline at end of file diff --git a/bubble sort.cpp b/bubble sort.cpp deleted file mode 100644 index 021e9ed..0000000 --- a/bubble sort.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -void swap(int *a,int *b) -{ - int tmp; - tmp=*a; - *a=*b; - *b=tmp; -} - -main() -{ - int a[10],i,j; - for(i=0;i<10;i++) - scanf("%d",&a[i]); - for(i=8;i>=0;i--) - { - for(j=0;j<=i;j++) - { - if(a[j]>a[j+1]) - { - swap(&a[j],&a[j+1]); - } - } - } - printf("After bubble sort array is : \n"); - for(i=0;i<10;i++) - printf("%d\n",a[i]); - -} - - diff --git a/calculator.c b/calculator.c deleted file mode 100644 index c0ce7cc..0000000 --- a/calculator.c +++ /dev/null @@ -1,32 +0,0 @@ -//C program to display simple calculator. - -#include -#include -int main() -{ - float n1,n2; //Declaring two float varibles, which we will later use as two operands. - char operator; //The operator is a char varible which will store our choice of operator. ex. +, -, *, / - printf("Enter an operator(+,-,/,*,^):"); - scanf("%c",&operator); //Taking input from user as what operation they want to perform. - - printf("Enter two numbers:"); - scanf("%f%f",&n1,&n2); //Taking float inputs as operands and storing then in n1 and n2 respectively - - switch(operator) //Here depending upon the operator input switch statement will decide which case to execute - { - //The %.3f will allow only three values after the dot(.) to print in the float - case'+' : printf("%.3f + %.3f = %.3f",n1,n2,(n1+n2)); - break; - case'-' : printf("%.3f - %.3f = %.3f",n1,n2,(n1-n2)); - break; - case'/' : printf("%.3f / %.3f = %.3f",n1,n2,(n1/n2)); - break; - case'*' : printf("%.3f * %.3f = %.3f",n1,n2,(n1*n2)); - break; - case'^' : printf("%.3f ^ %.3f = %.3f",n1,n2,pow(n1, n2)); - break; - default: printf("Error! operator is wrong"); - - } - return 0; -} diff --git a/countdigit.c b/countdigit.c deleted file mode 100644 index 8101a7c..0000000 --- a/countdigit.c +++ /dev/null @@ -1,18 +0,0 @@ -//C program to count number of digits in a number. - -#include -int main() -{ - int n,count=0; - printf("Enter a number:"); - scanf("%d",&n); - - while(n!=0) - { - n=n/10; - count++; - } - printf("Count of digits=%d",count); - - return 0; -} diff --git a/difference.c b/difference.c deleted file mode 100644 index 4766f36..0000000 --- a/difference.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -int main() -{ - int n1,n2; - float num1,num2; - char ch; - printf("Press 'i' for int and 'f' for float): "); - scanf("%c",&ch); - if(ch=='i'){ - printf("Enter two numbers:"); - scanf("%d%d",&n1,&n2); - } - else{ - printf("Enter two numbers:"); - scanf("%f%f",&num1,&num2); - } - switch(ch) - { - case 'i': - printf("The Difference of %d and %d is: %d",n1,n2,n1-n2); - break; - case 'f': - printf("The Difference of %f and %f is: %.2f",num1,num2,num1-num2); - break; - default: - printf("Wrong Choice!!!"); - } - return 0; -} diff --git a/divide.c b/divide.c deleted file mode 100644 index 7192de9..0000000 --- a/divide.c +++ /dev/null @@ -1,11 +0,0 @@ -//C program to divide two numbers. - -#include -int main() -{ - float n1,n2,div; - printf("Enter two numbers:");// Take input from user - scanf("%f%f",&n1,&n2); - div=n1/n2; // for divide users number - printf("Division of two numbers=%.3f",div);// give output of the users input -} diff --git a/divisionalt.c b/divisionalt.c deleted file mode 100644 index ecd4bc2..0000000 --- a/divisionalt.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -int main() -{ - float a,b,div; // variable declaration - printf("Enter values of two numbers:"); - scanf("%f%f",&a,&b); - if(b==0) - { - printf("Infinity"); - } - else - { - div=a/b; - printf("Division of two numbers=%.3f",div); - } -} diff --git a/divisionarray.c b/divisionarray.c deleted file mode 100644 index cea7303..0000000 --- a/divisionarray.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -void main() -{ - int arr1[5],arr2[5],arr3[5],i; - printf("Enter 5 values in arr1:"); - for(i=0;i<5;i++) - { - scanf("%d",&arr1[i]); - } - printf("Enter 5 values in arr2:"); - for(i=0;i<5;i++) - { - scanf("%d",&arr2[i]); - } - for(i=0;i<5;i++) - { - arr3[i]=arr1[i]/arr2[i]; - } - printf("Division of two arrays:"); - for(i=0;i<5;i++) - { - printf("%d\t",arr3[i]); - - } - - -} diff --git a/dowhile50.c b/dowhile50.c deleted file mode 100644 index 490bfb3..0000000 --- a/dowhile50.c +++ /dev/null @@ -1,11 +0,0 @@ -//C program to print 50 natural numbers using do-while loop. - -#include -int main() -{ int i=1; -do{ - printf("%d\t",i); - i++; - } while(i<=50); -} - diff --git a/even.c b/even.c deleted file mode 100644 index ae71b50..0000000 --- a/even.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to find out a number is even or not. - -#include -void main() -{ int numb,i; -printf("Enter a number:"); -scanf("%d",&numb); -if(numb%2==0) // condition to check even logic -{ -printf("A even number"); -} -else -{ -printf("A odd number"); -} - -} diff --git a/evenarray.c b/evenarray.c deleted file mode 100644 index d4be508..0000000 --- a/evenarray.c +++ /dev/null @@ -1,21 +0,0 @@ -//C program to input 5 numbers from user and display only even numbers using array. -//sampoorna -#include -int main() -{ - int a[5],i; - printf("Enter 5 numbers:"); - - for(i=0;i<=4;i++) - { - scanf("%d",&a[i]); - } - printf("Even numbers:"); - for(i=0;i<=4;i++) - { - if(a[i]%2==0) - { - printf("%d\t",a[i]); - } - } -} diff --git a/factorial.c b/factorial.c deleted file mode 100644 index ccd3344..0000000 --- a/factorial.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to find factorial of inputted number. - -#include -int main() -{ - int i,a,fact=1; - printf("Enter a number:"); - scanf("%d",&a); - for(i=1;i<=a;i++) - { - fact=fact*i; - } - printf("Factorial of a number=%d",fact); -} diff --git a/factors.c b/factors.c deleted file mode 100644 index 9e4238f..0000000 --- a/factors.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to find factors of any inputted number. - -#include -int main() -{ - int num,i; - printf("Enter a number:"); - scanf("%d",&num); - printf("Factors of a number=%d\n",num); - for(i=1;i<=num;i++) - { - if(num%i==0) - { - printf("%d\t",i); - } - } -} diff --git a/fibonacci.c b/fibonacci.c deleted file mode 100644 index 111f9e3..0000000 --- a/fibonacci.c +++ /dev/null @@ -1,18 +0,0 @@ -//C program to display Fibonacci sequence. - -#include -int main() -{ - int n1=0,n2=1,t,a,i; - printf("Enter no of terms:"); - scanf("%d",&a); - - printf("Fibonacci sequence:"); - for(i=1;i<=a;i++) - { - printf("%d\t",n1); - t=n1+n2; - n1=n2; - n2=t; -} -} diff --git a/fibonacci1.c b/fibonacci1.c deleted file mode 100644 index 5747032..0000000 --- a/fibonacci1.c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to display Fibonacci sequence in another form. - -#include -int main() -{ - int a=0,b=1,c,n,i; - printf("Enter no of terms:"); - scanf("%d",&n); - - printf("Fibonacci sequence:"); - for(i=1;i<=(n-2);i++) - { - printf("%d\t",a); - printf("%d\t",b); - c=a+b; - printf("%d",c); - a=b; - c=b; - } -} diff --git a/fileHandling.c b/fileHandling.c deleted file mode 100644 index a1eb207..0000000 --- a/fileHandling.c +++ /dev/null @@ -1,52 +0,0 @@ -/*This code shows the use of file handling which is - *very useful when it comes to projects in C -*/ -#include -#include -#include -int primeTest(int n) -{ - int j,flag=-1; - for(j=2;j<=sqrt(n);j++) - { - if(n%j==0) - { - flag=1; - break; - } - } - if(flag==1) - return 0; - else - return 1; -} -int main() -{ - int i; - char c; - FILE *src,*trg; - src=fopen("source.txt","w"); - if(src==NULL) - { - printf("ERROR IN OPENING FILE\n"); - return 0; - } - for(i=1001;i<10000;i++) - fprintf(src,"%d ",i); - fclose(src); - trg=fopen("target.txt","w"); - src=fopen("source.txt","r"); - if(trg==NULL || src==NULL) - { - printf("ERROR IN OPENING FILE\n"); - return 0; - } - - while((fscanf(src,"%d",&i))!=-1) - { - if(primeTest(i)) - fprintf(trg,"%d ",i); - } - fclose(src); - fclose(trg); -} diff --git a/fileHandlingSimple.c b/fileHandlingSimple.c deleted file mode 100644 index 61c63c4..0000000 --- a/fileHandlingSimple.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -int main(){ - - FILE *fp; //Declaring a FILE pointer - - //Opening the file - fp = fopen("FILE.txt", "w"); //Assigning FILE pointer an address(name) of our file and mode of use in double quotes. - int x = 10; //Here "w" stands for writting only. if file does not exist it will create it by itself. - // "r" stands for read only. file must be existing compulsary. - // "a" stands for append only(writes file without removing previuosly present content). if file does not exist it will create it by itself. - // "r+" stands for read + Write. But when you complete your Writting/Reading part dont forget to use rewind(fp) function unless it won't work. - // "w+" stands for write + read. But when you complete your Writting/Reading part dont forget to use rewind(fp) function unless it won't work. - // "a+" stands for append + read. But when you complete your Writting/Reading part dont forget to use rewind(fp) function unless it won't work. - - - //Saving Data to FILE.txt - fprintf(fp ,"Hello World %d", x); //Saving data to file by using fprintf( file_pointer ,"Format_specifiers" , Arguments); - fclose(fp); //Closing file by using fclose( file_pointer ) function.Closing file after use is considered as a good practice. - - - //Opening the file - fp = fopen("FILE.txt", "r"); //Using FILE.txt in "r"(read mode). - - - int y; //An integer buffer to save scanned(readed) value from file. - char first[10]; //An character array buffer to save scanned(readed) value from file. - char second[10]; //An character array buffer to save scanned(readed) value from file. - - //Reading Data from FILE.txt - fscanf(fp, "%s%s%d", first, second, &y); //Scaing(reading) two strings and one integer value from file using fscanf( file_pointer, "format_specifiers" ,Arguments); - printf("%s %s %d", first, second, y); //Printing the scanned files - fclose(fp); //Closing file by using fclose( file_pointer ) function.Closing file after use is considered as a good practice. - - - return 0; -} diff --git a/find_leap_year.c b/find_leap_year.c deleted file mode 100644 index a1222fa..0000000 --- a/find_leap_year.c +++ /dev/null @@ -1,29 +0,0 @@ -/*C program to print all leap years from 1 to N.*/ - -#include - -//function to check leap year -int checkLeapYear(int year) -{ - if( (year % 400==0)||(year%4==0 && year%100!=0) ) - return 1; - else - return 0; -} - -int main() -{ - int i,n; - - printf("Enter the value of N: "); - scanf("%d",&n); - - printf("Leap years from 1 to %d:\n",n); - for(i=1;i<=n;i++) - { - if(checkLeapYear(i)) - printf("%d\t",i); - } - - return 0; -} diff --git a/first&lastdigit.c b/first&lastdigit.c deleted file mode 100644 index 5e8133b..0000000 --- a/first&lastdigit.c +++ /dev/null @@ -1,22 +0,0 @@ -//C program to find first and last digit of a number. - -#include -int main() -{ - int num,i,fd,ld; - printf("Enter a number:"); - scanf("%d",&num); - - i=num; - ld=num%10; - while(i>0) - { - if(i/10==0){ - fd=i%10; - } - i=i/10; - } - printf("First digit of a number=%d",fd); - printf("Last digit of a number=%d",ld); - return 0; -} diff --git a/frequency.c b/frequency.c deleted file mode 100644 index d7b96bb..0000000 --- a/frequency.c +++ /dev/null @@ -1,19 +0,0 @@ -//C program to find frequency of a digit in inputted number. - -#include -int main() -{ - int num,digit,t,count=0; - printf("Enter a number:"); - scanf("%d",&num); - printf("Enter the digit to be counted:"); - scanf("%d",&digit); - while(num!=0) - { - t=num%10; - if(t==digit) - count++; - num=num/10; - } - printf("The digit %d presents %d times",digit,count); - } diff --git a/function50even(1).c b/function50even(1).c deleted file mode 100644 index 62e0245..0000000 --- a/function50even(1).c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to print only even numbers from 1 to 50 using function. - -#include -int even(int i); -void main() -{ - int i; - int x=even(i); -} -int even(int i) -{ - for(i=1;i<=50;i++) - { - if(i%2==0) - printf("%d\t",i); - } -} diff --git a/function50even.c b/function50even.c deleted file mode 100644 index 62e0245..0000000 --- a/function50even.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to print only even numbers from 1 to 50 using function. - -#include -int even(int i); -void main() -{ - int i; - int x=even(i); -} -int even(int i) -{ - for(i=1;i<=50;i++) - { - if(i%2==0) - printf("%d\t",i); - } -} diff --git a/functionadd(1).c b/functionadd(1).c deleted file mode 100644 index 972e238..0000000 --- a/functionadd(1).c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to add two numbers using functions of -type with no arguments and no return type*/ - -#include -void sum(); -void main() -{ - sum(); -} -void sum() -{ - int a,b,sum; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - sum=a+b; - printf("Sum of two numbers=%d",sum); -} diff --git a/functionadd.c b/functionadd.c deleted file mode 100644 index 9b0d665..0000000 --- a/functionadd.c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to add two numbers using functions of -type with no arguments and no return type*/ - -#include -void sum(); // function for adding two numbers -void main() -{ - sum(); -} -void sum() -{ - int a,b,sum; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - sum=a+b; - printf("Sum of two numbers=%d",sum); -} diff --git a/functionadd1(1).c b/functionadd1(1).c deleted file mode 100644 index c906a97..0000000 --- a/functionadd1(1).c +++ /dev/null @@ -1,18 +0,0 @@ -/*C program to add two numbers using function of -type with no arguments but return type*/ - -#include -int sum(); -void main() -{ - int add=sum(); -} -int sum() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a+b); -} diff --git a/functionadd1.c b/functionadd1.c deleted file mode 100644 index c906a97..0000000 --- a/functionadd1.c +++ /dev/null @@ -1,18 +0,0 @@ -/*C program to add two numbers using function of -type with no arguments but return type*/ - -#include -int sum(); -void main() -{ - int add=sum(); -} -int sum() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a+b); -} diff --git a/functionadd2.c(1).c b/functionadd2.c(1).c deleted file mode 100644 index 1ce18ea..0000000 --- a/functionadd2.c(1).c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to add two numbers using functions of -type with arguments but no return type*/ - -#include -void sum(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter two number:"); - scanf("%d",&b); - sum(a,b); -} -void sum(int a,int b) -{ - int sum; - sum=a+b; - printf("Sum of two numbers=%d",sum); -} diff --git a/functionadd2.c.c b/functionadd2.c.c deleted file mode 100644 index 1ce18ea..0000000 --- a/functionadd2.c.c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to add two numbers using functions of -type with arguments but no return type*/ - -#include -void sum(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter two number:"); - scanf("%d",&b); - sum(a,b); -} -void sum(int a,int b) -{ - int sum; - sum=a+b; - printf("Sum of two numbers=%d",sum); -} diff --git a/functionadd3(1).c b/functionadd3(1).c deleted file mode 100644 index a06ff35..0000000 --- a/functionadd3(1).c +++ /dev/null @@ -1,22 +0,0 @@ -/*C program to add two numbers using functions of -type with arguments and return type*/ -//samporn -#include -int sum(int a,int b); -int main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int add=sum(a,b); - printf("Sum of two numbers=%d",add); -} - -int sum(int a,int b) -{ - int sum; - sum=a+b; - return sum; -} diff --git a/functionadd3.c b/functionadd3.c deleted file mode 100644 index 83d089b..0000000 --- a/functionadd3.c +++ /dev/null @@ -1,22 +0,0 @@ -/*C program to add two numbers using functions of -type with arguments and return type*/ - -#include -int sum(int a,int b); -int main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int add=sum(a,b); - printf("Sum of two numbers=%d",add); -} - -int sum(int a,int b) -{ - int sum; - sum=a+b; - return sum; -} diff --git a/functionarmstrong(1).c b/functionarmstrong(1).c deleted file mode 100644 index d2a415c..0000000 --- a/functionarmstrong(1).c +++ /dev/null @@ -1,34 +0,0 @@ -//C program to check whether a number is armstrong or not using function. - -#include -int armstrong(int num,int num1,int rem,int res); -void main() -{ - int num,num1,rem,res=0; - printf("Enter a number:"); - scanf("%d",&num); - int result=armstrong(num,num1,rem,res); - if(result==1) - { - printf("An armstrong number"); - } - else - { - printf("Not an armstrong number"); - } -} -int armstrong(int num,int num1,int rem,int res) -{ - num1=num; - - while(num1!=0) - { - rem=num1%10; - res+=rem*rem*rem; - num1=num1/10; - } - if(res==num) - return 1; - else - return 0; -} diff --git a/functionarmstrong.c b/functionarmstrong.c deleted file mode 100644 index d2a415c..0000000 --- a/functionarmstrong.c +++ /dev/null @@ -1,34 +0,0 @@ -//C program to check whether a number is armstrong or not using function. - -#include -int armstrong(int num,int num1,int rem,int res); -void main() -{ - int num,num1,rem,res=0; - printf("Enter a number:"); - scanf("%d",&num); - int result=armstrong(num,num1,rem,res); - if(result==1) - { - printf("An armstrong number"); - } - else - { - printf("Not an armstrong number"); - } -} -int armstrong(int num,int num1,int rem,int res) -{ - num1=num; - - while(num1!=0) - { - rem=num1%10; - res+=rem*rem*rem; - num1=num1/10; - } - if(res==num) - return 1; - else - return 0; -} diff --git a/functionaverage(1).c b/functionaverage(1).c deleted file mode 100644 index fb07f89..0000000 --- a/functionaverage(1).c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to find average of 5 numbers using -functions(with arguments,return type)*/ - -#include -float avg(float n1,float n2,float n3,float n4,float n5); -void main() -{ - float n1,n2,n3,n4,n5; - printf("Enter five numbers:"); - scanf("%f%f%f%f%f",&n1,&n2,&n3,&n4,&n5); - float average=avg(n1,n2,n3,n4,n5); - printf("Average of five numbers=%f",average); -} -float avg(float n1,float n2,float n3,float n4,float n5) -{ - float avg; - avg=(n1+n2+n3+n4+n5/5.0); - return avg; -} diff --git a/functionaverage.c b/functionaverage.c deleted file mode 100644 index 7cb7e99..0000000 --- a/functionaverage.c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to find average of 5 numbers using -functions(with arguments,return type)*/ - -#include -float avg(float n1,float n2,float n3,float n4,float n5); //function to find the average of given 5 numbers -void main() -{ - float n1,n2,n3,n4,n5; - printf("Enter five numbers:"); - scanf("%f%f%f%f%f",&n1,&n2,&n3,&n4,&n5); - float average=avg(n1,n2,n3,n4,n5); - printf("Average of five numbers=%f",average); -} -float avg(float n1,float n2,float n3,float n4,float n5) -{ - float avg; - avg=(n1+n2+n3+n4+n5/5.0); - return avg; -} diff --git a/functionaverage1(1).c b/functionaverage1(1).c deleted file mode 100644 index d5f00c6..0000000 --- a/functionaverage1(1).c +++ /dev/null @@ -1,24 +0,0 @@ -/*C program to find average of five numbers in another format using -function of type(with arguments,return type)*/ - -#include -void avg(); -void main() -{ - avg(); -} -void avg() -{ - int i,n,sum=0; - float avg; - printf("Enter five numbers:"); - scanf("%d",&n); - for(i=1;i<=5;i++) - { - sum=sum+n; - } - avg=(sum/5.0); - printf("Average of five numbers=%f",avg); - - -} diff --git a/functionaverage1.c b/functionaverage1.c deleted file mode 100644 index d5f00c6..0000000 --- a/functionaverage1.c +++ /dev/null @@ -1,24 +0,0 @@ -/*C program to find average of five numbers in another format using -function of type(with arguments,return type)*/ - -#include -void avg(); -void main() -{ - avg(); -} -void avg() -{ - int i,n,sum=0; - float avg; - printf("Enter five numbers:"); - scanf("%d",&n); - for(i=1;i<=5;i++) - { - sum=sum+n; - } - avg=(sum/5.0); - printf("Average of five numbers=%f",avg); - - -} diff --git a/functioncount(1).c b/functioncount(1).c deleted file mode 100644 index 9312812..0000000 --- a/functioncount(1).c +++ /dev/null @@ -1,21 +0,0 @@ -//C program to count number of digits in a number using function. - -#include -int digit(int num,int count); -void main() -{ - int num,count=0; - printf("Enter a number:"); - scanf("%d",&num); - int y=digit(num,count); - printf("Count of digits in a number=%d",y); -} -int digit(int num,int count) -{ - while(num!=0) - { - num=num/10; - count++; - } - return count; -} diff --git a/functioncount.c b/functioncount.c deleted file mode 100644 index 9312812..0000000 --- a/functioncount.c +++ /dev/null @@ -1,21 +0,0 @@ -//C program to count number of digits in a number using function. - -#include -int digit(int num,int count); -void main() -{ - int num,count=0; - printf("Enter a number:"); - scanf("%d",&num); - int y=digit(num,count); - printf("Count of digits in a number=%d",y); -} -int digit(int num,int count) -{ - while(num!=0) - { - num=num/10; - count++; - } - return count; -} diff --git a/functiondivide1(1).c b/functiondivide1(1).c deleted file mode 100644 index d6b6e9c..0000000 --- a/functiondivide1(1).c +++ /dev/null @@ -1,18 +0,0 @@ -/*C program to divide two numbers using functions -of type with no argument but return type*/ - -#include -int div(); -void main() -{ - int t=div(); -} - int div() - { - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - return(a/b); - } diff --git a/functiondivide1.c b/functiondivide1.c deleted file mode 100644 index d6b6e9c..0000000 --- a/functiondivide1.c +++ /dev/null @@ -1,18 +0,0 @@ -/*C program to divide two numbers using functions -of type with no argument but return type*/ - -#include -int div(); -void main() -{ - int t=div(); -} - int div() - { - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - return(a/b); - } diff --git a/functiondivide2(1).c b/functiondivide2(1).c deleted file mode 100644 index 3ed0c12..0000000 --- a/functiondivide2(1).c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to divide two numbers using functions -of type with arguments but no return type*/ - -#include -void div(int a,int b); -void main() -{ - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - div(a,b); -} -void div(int a,int b) -{ - int t; - t=a/b; - printf("Division of two numbers=%d",t); -} diff --git a/functiondivide2.c b/functiondivide2.c deleted file mode 100644 index 3ed0c12..0000000 --- a/functiondivide2.c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to divide two numbers using functions -of type with arguments but no return type*/ - -#include -void div(int a,int b); -void main() -{ - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - div(a,b); -} -void div(int a,int b) -{ - int t; - t=a/b; - printf("Division of two numbers=%d",t); -} diff --git a/functiondivision(1).c b/functiondivision(1).c deleted file mode 100644 index df41b48..0000000 --- a/functiondivision(1).c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to divide two numbers using functions -of type with no arguments and no return type*/ - -#include -void div(); -void main() -{ - div(); -} -void div() -{ - int a,b,div; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - div=a/b; - printf("Division of two numbers=%d",div); -} diff --git a/functiondivision.c b/functiondivision.c deleted file mode 100644 index df41b48..0000000 --- a/functiondivision.c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to divide two numbers using functions -of type with no arguments and no return type*/ - -#include -void div(); -void main() -{ - div(); -} -void div() -{ - int a,b,div; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - div=a/b; - printf("Division of two numbers=%d",div); -} diff --git a/functiondivision3(1).c b/functiondivision3(1).c deleted file mode 100644 index 4aebebe..0000000 --- a/functiondivision3(1).c +++ /dev/null @@ -1,24 +0,0 @@ -/*C program to divide two numbers using functions -of type with arguments and return type*/ - -#include -int div(int a,int b); -void main() -{ - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - int t=div(a,b); - printf("Division of two numbers=%d",t); - - -} - -int div(int a,int b) -{ - int t; - t=a/b; - return t; -} diff --git a/functiondivision3.c b/functiondivision3.c deleted file mode 100644 index 4aebebe..0000000 --- a/functiondivision3.c +++ /dev/null @@ -1,24 +0,0 @@ -/*C program to divide two numbers using functions -of type with arguments and return type*/ - -#include -int div(int a,int b); -void main() -{ - int a,b; - printf("Enter numerator:"); - scanf("%d",&a); - printf("Enter denominator:"); - scanf("%d",&b); - int t=div(a,b); - printf("Division of two numbers=%d",t); - - -} - -int div(int a,int b) -{ - int t; - t=a/b; - return t; -} diff --git a/functionevenodd(1).c b/functionevenodd(1).c deleted file mode 100644 index 94ce3b0..0000000 --- a/functionevenodd(1).c +++ /dev/null @@ -1,23 +0,0 @@ -//C program to check whether a number is even or odd using function. - -#include -int evenodd(int num); -int main() -{ - int num; - printf("Enter a number"); - scanf("%d",&num); - evenodd(num); - return 0; -} -int evenodd(int num) -{ - if(num%2==0) - { - printf("An even number"); - } - else - { - printf("An odd number"); - } -} diff --git a/functionevenodd.c b/functionevenodd.c deleted file mode 100644 index 94ce3b0..0000000 --- a/functionevenodd.c +++ /dev/null @@ -1,23 +0,0 @@ -//C program to check whether a number is even or odd using function. - -#include -int evenodd(int num); -int main() -{ - int num; - printf("Enter a number"); - scanf("%d",&num); - evenodd(num); - return 0; -} -int evenodd(int num) -{ - if(num%2==0) - { - printf("An even number"); - } - else - { - printf("An odd number"); - } -} diff --git a/functionevenodd1(1).c b/functionevenodd1(1).c deleted file mode 100644 index 0cf91cf..0000000 --- a/functionevenodd1(1).c +++ /dev/null @@ -1,30 +0,0 @@ -//C program to check whether a number is even or odd. - -#include -int evenodd(int num); -int main() -{ - int num,t; - printf("Enter a number:"); - scanf("%d",&num); - t=evenodd(num); - if(t==1) - { - printf("An even number"); - } - else if(t==0) - { - printf("An odd number"); - - } -} -int evenodd(int num) - { - if(num%2==0) - return 1; - else - return 0; - } - - - diff --git a/functionevenodd1.c b/functionevenodd1.c deleted file mode 100644 index 0cf91cf..0000000 --- a/functionevenodd1.c +++ /dev/null @@ -1,30 +0,0 @@ -//C program to check whether a number is even or odd. - -#include -int evenodd(int num); -int main() -{ - int num,t; - printf("Enter a number:"); - scanf("%d",&num); - t=evenodd(num); - if(t==1) - { - printf("An even number"); - } - else if(t==0) - { - printf("An odd number"); - - } -} -int evenodd(int num) - { - if(num%2==0) - return 1; - else - return 0; - } - - - diff --git a/functionfact(1).c b/functionfact(1).c deleted file mode 100644 index dee15c0..0000000 --- a/functionfact(1).c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to find the factorial of an inputted number using function. - -#include -int factorial(int n,int i,int fact); -void main() -{ - int n,i,fact=1; - printf("Enter a number:"); - scanf("%d",&n); - int t=factorial(n,i,fact); - printf("Factorial of number=%d",t); -} -int factorial(int n,int i,int fact) -{ - for(i=1;i<=n;i++) - { - fact=fact*i; - } - return fact; -} diff --git a/functionfact.c b/functionfact.c deleted file mode 100644 index dee15c0..0000000 --- a/functionfact.c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to find the factorial of an inputted number using function. - -#include -int factorial(int n,int i,int fact); -void main() -{ - int n,i,fact=1; - printf("Enter a number:"); - scanf("%d",&n); - int t=factorial(n,i,fact); - printf("Factorial of number=%d",t); -} -int factorial(int n,int i,int fact) -{ - for(i=1;i<=n;i++) - { - fact=fact*i; - } - return fact; -} diff --git a/functionfibonacci(1).c b/functionfibonacci(1).c deleted file mode 100644 index 6d947bb..0000000 --- a/functionfibonacci(1).c +++ /dev/null @@ -1,28 +0,0 @@ -//C program to display fibonacci series using function. - -#include -int fib(int n,int i); -int main() -{ - int n1=0,n2=1,n,i,x; - printf("Enter no of terms:"); - scanf("%d",&n); - printf("Fibonacci sequence is:"); - printf("%d\t",n1); - printf("%d\t",n2); - x=fib(n,i); - printf("%d\t",x); -} -int fib(int n,int i) -{ - int n1=0,n2=1,sum; - int t; - for(i=1;i<=(n-2);i++) - { - t=n1+n2; - printf("%d\t",t); - n1=n2; - n2=t; - } - return t; -} diff --git a/functionfibonacci.c b/functionfibonacci.c deleted file mode 100644 index 6d947bb..0000000 --- a/functionfibonacci.c +++ /dev/null @@ -1,28 +0,0 @@ -//C program to display fibonacci series using function. - -#include -int fib(int n,int i); -int main() -{ - int n1=0,n2=1,n,i,x; - printf("Enter no of terms:"); - scanf("%d",&n); - printf("Fibonacci sequence is:"); - printf("%d\t",n1); - printf("%d\t",n2); - x=fib(n,i); - printf("%d\t",x); -} -int fib(int n,int i) -{ - int n1=0,n2=1,sum; - int t; - for(i=1;i<=(n-2);i++) - { - t=n1+n2; - printf("%d\t",t); - n1=n2; - n2=t; - } - return t; -} diff --git a/functionfirst&last.c b/functionfirst&last.c deleted file mode 100644 index b07eb42..0000000 --- a/functionfirst&last.c +++ /dev/null @@ -1,34 +0,0 @@ -//C program to find the first and last digit of a number using function. - -#include -int digit(int num,int i,int ld); -int digit1(int num,int i,int fd); -void main() -{ - int num,i,ld,fd; - printf("Enter a number:"); - scanf("%d",&num); - i=num; - int x=digit(num,i,ld); - int y=digit1(num,i,fd); - printf("Last digit of number=%d\n",x); - printf("First digit of number=%d\n",y); - - -} -int digit(int num,int i,int ld) -{ - ld=num%10; - return ld; -} -int digit1(int num,int i,int fd) -{ - while(i>0) - { - if(i/10==0) { - fd=i%10; - } - i=i/10; - } - return fd; -} diff --git a/functionfreq.c b/functionfreq.c deleted file mode 100644 index bc11d79..0000000 --- a/functionfreq.c +++ /dev/null @@ -1,25 +0,0 @@ -//C program to calculate frequency of a digit in a number using function. - -#include -int freq(int,int,int,int ); -void main() -{ - int num,digit,t,count=0; - printf("Enter a number:"); - scanf("%d",&num); - printf("Enter the digit to be counted:"); - scanf("%d",&digit); - int res=freq(num,digit,count,t); - -} -int freq(int num,int digit,int count,int t) -{ - while(num!=0) - { - t=num%10; - if(t==digit) - count++; - num=num/10; - } - printf("The digit %d presents %d times",digit,count); -} diff --git a/functionhcflcm(1).c b/functionhcflcm(1).c deleted file mode 100644 index 8c946d1..0000000 --- a/functionhcflcm(1).c +++ /dev/null @@ -1,41 +0,0 @@ -//C program to find HCF and LCM of two numbers using function. - -#include -int result(int a,int b,int x,int y,int t,int hcf); -int res(int x,int y,int i,int lcm,int gcd); -void main() -{ - int a,b,x,y,i,t,hcf,lcm,gcd; - printf("Enter two integers:"); - scanf("%d%d",&x,&y); - a=x; - b=y; - int z=result(a,b,x,y,t,hcf); - int v=res(x,y,i,lcm,gcd); - printf("Hcf of %d and %d = %d",x,y,z); - printf("Lcm of %d and %d = %d",x,y,v); -} -int result(int a,int b,int x,int y,int t,int hcf) -{ - while(b!=0) - { - t=b; - a=a%b; - a=t; - b--; - } - hcf=a; - return hcf; -} -int res(int x,int y,int i,int lcm,int gcd) -{ - for(i=1;i<=x && i<=y;i++) - { - if(x%i==0 & y%i==0) - { - gcd=i; - } - lcm=(x*y)/gcd; - return lcm; - } -} diff --git a/functionhcflcm.c b/functionhcflcm.c deleted file mode 100644 index 8c946d1..0000000 --- a/functionhcflcm.c +++ /dev/null @@ -1,41 +0,0 @@ -//C program to find HCF and LCM of two numbers using function. - -#include -int result(int a,int b,int x,int y,int t,int hcf); -int res(int x,int y,int i,int lcm,int gcd); -void main() -{ - int a,b,x,y,i,t,hcf,lcm,gcd; - printf("Enter two integers:"); - scanf("%d%d",&x,&y); - a=x; - b=y; - int z=result(a,b,x,y,t,hcf); - int v=res(x,y,i,lcm,gcd); - printf("Hcf of %d and %d = %d",x,y,z); - printf("Lcm of %d and %d = %d",x,y,v); -} -int result(int a,int b,int x,int y,int t,int hcf) -{ - while(b!=0) - { - t=b; - a=a%b; - a=t; - b--; - } - hcf=a; - return hcf; -} -int res(int x,int y,int i,int lcm,int gcd) -{ - for(i=1;i<=x && i<=y;i++) - { - if(x%i==0 & y%i==0) - { - gcd=i; - } - lcm=(x*y)/gcd; - return lcm; - } -} diff --git a/functionisLargest(1).c b/functionisLargest(1).c deleted file mode 100644 index 0a32086..0000000 --- a/functionisLargest(1).c +++ /dev/null @@ -1,19 +0,0 @@ -//C program to find largest among two numbers using function. - -#include -int isLargest(int n1,int n2); -void main() -{ - int n1,n2; - printf("Enter two numbers:"); - scanf("%d%d",&n1,&n2); - int x=isLargest(n1,n2); - printf("%d is largest among two numbers",x); -} -int isLargest(int n1,int n2) -{ - if(n1>n2) - return n1; -else - return n2; -} diff --git a/functionisLargest.c b/functionisLargest.c deleted file mode 100644 index 0a32086..0000000 --- a/functionisLargest.c +++ /dev/null @@ -1,19 +0,0 @@ -//C program to find largest among two numbers using function. - -#include -int isLargest(int n1,int n2); -void main() -{ - int n1,n2; - printf("Enter two numbers:"); - scanf("%d%d",&n1,&n2); - int x=isLargest(n1,n2); - printf("%d is largest among two numbers",x); -} -int isLargest(int n1,int n2) -{ - if(n1>n2) - return n1; -else - return n2; -} diff --git a/functionisLargest3(1).c b/functionisLargest3(1).c deleted file mode 100644 index 60abc7c..0000000 --- a/functionisLargest3(1).c +++ /dev/null @@ -1,27 +0,0 @@ -//C program to find largest among three numbers using function. - -#include -int isLargest3(int n1,int n2,int n3); -void main() -{ - int n1,n2,n3; - printf("Enter three numbers:"); - scanf("%d%d%d",&n1,&n2,&n3); - int max=isLargest3(n1,n2,n3); - printf("%d is the largest among three numbers",max); - -} -int isLargest3(int n1,int n2,int n3) -{ - if(n1>n2) - { - if(n1>n3) - return n1; - else - return n3; - } - if(n2>n3) - return n2; - else - return n3; -} diff --git a/functionisLargest3.c b/functionisLargest3.c deleted file mode 100644 index 60abc7c..0000000 --- a/functionisLargest3.c +++ /dev/null @@ -1,27 +0,0 @@ -//C program to find largest among three numbers using function. - -#include -int isLargest3(int n1,int n2,int n3); -void main() -{ - int n1,n2,n3; - printf("Enter three numbers:"); - scanf("%d%d%d",&n1,&n2,&n3); - int max=isLargest3(n1,n2,n3); - printf("%d is the largest among three numbers",max); - -} -int isLargest3(int n1,int n2,int n3) -{ - if(n1>n2) - { - if(n1>n3) - return n1; - else - return n3; - } - if(n2>n3) - return n2; - else - return n3; -} diff --git a/functionnum50(1).c b/functionnum50(1).c deleted file mode 100644 index 593585a..0000000 --- a/functionnum50(1).c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to print numbers from 1 to 50 using function. - -#include -int num(int i); -void main() -{ - int i; - int t=num(i); -} -int num(int i) -{ - for(i=1;i<=50;i++) - printf("%d\t",i); -} diff --git a/functionnum50.c b/functionnum50.c deleted file mode 100644 index 593585a..0000000 --- a/functionnum50.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to print numbers from 1 to 50 using function. - -#include -int num(int i); -void main() -{ - int i; - int t=num(i); -} -int num(int i) -{ - for(i=1;i<=50;i++) - printf("%d\t",i); -} diff --git a/functionpalindrome(1).c b/functionpalindrome(1).c deleted file mode 100644 index bb7c4f5..0000000 --- a/functionpalindrome(1).c +++ /dev/null @@ -1,31 +0,0 @@ -//C program to check a number is palindrome or not using function. - -#include -int palindrome(int num,int i,int rev); -int main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=palindrome(num,i,rev); - if(res==1) - { - printf("A palindrome number"); - } - else - { - printf("Not a palindrome number"); - } - return 0; -} -int palindrome(int num,int i,int rev) -{ - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - if(rev==num) - return 1; -else - return 0; -} diff --git a/functionpalindrome.c b/functionpalindrome.c deleted file mode 100644 index 9ca744b..0000000 --- a/functionpalindrome.c +++ /dev/null @@ -1,30 +0,0 @@ -//C program to check a number is palindrome or not using function. - -#include -int palindrome(int num,int i,int rev); -void main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=palindrome(num,i,rev); - if(res==1) - { - printf("A palindrome number"); - } - else - { - printf("Not a palindrome number"); - } -} -int palindrome(int num,int i,int rev) -{ - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - if(rev==num) - return 1; -else - return 0; -} diff --git a/functionposneg(1).c b/functionposneg(1).c deleted file mode 100644 index 21d792e..0000000 --- a/functionposneg(1).c +++ /dev/null @@ -1,32 +0,0 @@ -//C program to check whether number is positive,negative or zero using function. - -#include -int func(int num); -void main() -{ - int num; - printf("Enter a number:"); - scanf("%d",&num); - int n=func(num); - if(n==1) - { - printf("A negative number"); - } - else if(n==0) - { - printf("A positive number"); - } - else - { - printf("Zero"); - } -} -int func(int num) -{ - if(num<0) - return 1; -else if(num>0) - return 0; -else - return 2; -} diff --git a/functionposneg.c b/functionposneg.c deleted file mode 100644 index 21d792e..0000000 --- a/functionposneg.c +++ /dev/null @@ -1,32 +0,0 @@ -//C program to check whether number is positive,negative or zero using function. - -#include -int func(int num); -void main() -{ - int num; - printf("Enter a number:"); - scanf("%d",&num); - int n=func(num); - if(n==1) - { - printf("A negative number"); - } - else if(n==0) - { - printf("A positive number"); - } - else - { - printf("Zero"); - } -} -int func(int num) -{ - if(num<0) - return 1; -else if(num>0) - return 0; -else - return 2; -} diff --git a/functionprime(1).c b/functionprime(1).c deleted file mode 100644 index 15700e9..0000000 --- a/functionprime(1).c +++ /dev/null @@ -1,32 +0,0 @@ -//C program to check given number is even or not using function. - -#include -int prime(int num,int i,int count); -void main() -{ - int num,i,count=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=prime(num,i,count); - if(res==1) - { - printf("A prime number"); - } - else - { - printf("Not a prime number"); - } -} -int prime(int num,int i,int count) -{ - for(i=2;i<=num;i++) - { - if(num%i==0) - count++; - break; - } - if(count==0) - return 1; - else - return 0; -} diff --git a/functionprime.c b/functionprime.c deleted file mode 100644 index 260a4ee..0000000 --- a/functionprime.c +++ /dev/null @@ -1,32 +0,0 @@ -//C program to check given number is even or not using function. - -#include -int prime(int num,int i,int count); // function to check inputted number is prime or not. -void main() -{ - int num,i,count=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=prime(num,i,count); - if(res==1) - { - printf("A prime number"); - } - else - { - printf("Not a prime number"); - } -} -int prime(int num,int i,int count) //body of the function defined -{ - for(i=2;i<=num;i++) - { - if(num%i==0) - count++; - break; - } - if(count==0) - return 1; - else - return 0; -} diff --git a/functionprimeinrange(1).c b/functionprimeinrange(1).c deleted file mode 100644 index 91cfa55..0000000 --- a/functionprimeinrange(1).c +++ /dev/null @@ -1,30 +0,0 @@ -//C program to display all prime number between 1 to 100 using function. - -#include -int primein(int num,int i,int count); -void main() -{ - int num,i,count; - printf("Prime numbers between 1 to 100=%d",num); - int res=primein(num,i,count); - if(res==num) - { - printf("%d\t",res); - } -} - -int primein(int num,int i,int count) -{ -for(num=1;num<=100;num++) -{ - count=0; - for(i=2;i<=(num/2);i++) - { - if(num%i==0) - count++; - break; - } - if(count==0&&num!=1) - return num; -} -} diff --git a/functionprimeinrange.c b/functionprimeinrange.c deleted file mode 100644 index 350d3af..0000000 --- a/functionprimeinrange.c +++ /dev/null @@ -1,31 +0,0 @@ -//C program to display all prime number between 1 to 100 using function. - -#include -int primein(int num,int i,int count); -void main() -{ - int num,i,count; - printf("Prime numbers between 1 to 100=%d",num); - int res=primein(num,i,count); - if(res==num) - { - printf("%d\t",res); - } -} - -int primein(int num,int i,int count) -{ -for(num=1;num<=100;num++) -{ - count=0; - for(i=2;i<=(num/2);i++) - { - if(num%i==0) - count++; - break; - } - if(count==0&&num!=1) - return num; -} - return 0; -} diff --git a/functionproduct(1).c b/functionproduct(1).c deleted file mode 100644 index 2823410..0000000 --- a/functionproduct(1).c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to product two numbers using functions -of type with no arguments and no return type*/ - -#include -void prod(); -void main() -{ - prod(); -} -void prod() -{ - int a,b,prod; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - prod=a*b; - printf("Product of two numbers=%d",prod); - -} diff --git a/functionproduct.c b/functionproduct.c deleted file mode 100644 index f688882..0000000 --- a/functionproduct.c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to product two numbers using functions -of type with no arguments and no return type*/ - -#include -void prod(); -int main() -{ - prod(); -} -void prod() -{ - int a,b,prod; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - prod=a*b; - printf("Product of two numbers=%d",prod); - return 0; -} diff --git a/functionproduct1(1).c b/functionproduct1(1).c deleted file mode 100644 index 434078c..0000000 --- a/functionproduct1(1).c +++ /dev/null @@ -1,23 +0,0 @@ -/*C program to product two numbers using functions -of type with arguments but no return type*/ - -#include -void prod(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - prod(a,b); -} - -void prod(int a,int b) -{ - int prod; - prod=a*b; - printf("Product of two numbers=%d",prod); - - -} diff --git a/functionproduct1.c b/functionproduct1.c deleted file mode 100644 index 434078c..0000000 --- a/functionproduct1.c +++ /dev/null @@ -1,23 +0,0 @@ -/*C program to product two numbers using functions -of type with arguments but no return type*/ - -#include -void prod(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - prod(a,b); -} - -void prod(int a,int b) -{ - int prod; - prod=a*b; - printf("Product of two numbers=%d",prod); - - -} diff --git a/functionproduct2(1).c b/functionproduct2(1).c deleted file mode 100644 index fb088aa..0000000 --- a/functionproduct2(1).c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to product two numbers using functions -of type with no arguments but return type*/ - -#include -int prod(); -void main() -{ - int mult=prod(); -} -int prod() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a*b); - -} diff --git a/functionproduct2.c b/functionproduct2.c deleted file mode 100644 index fb088aa..0000000 --- a/functionproduct2.c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to product two numbers using functions -of type with no arguments but return type*/ - -#include -int prod(); -void main() -{ - int mult=prod(); -} -int prod() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a*b); - -} diff --git a/functionproduct3(1).c b/functionproduct3(1).c deleted file mode 100644 index 6f627d2..0000000 --- a/functionproduct3(1).c +++ /dev/null @@ -1,22 +0,0 @@ -/*C program to product two numbers using functions -of type with arguments and return type*/ - -#include -int prod(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int mult=prod(a,b); - printf("Product of two numbers=%d",mult); -} - -int prod(int a,int b) -{ - int prod; - prod=a*b; - return prod; -} diff --git a/functionproduct3.c b/functionproduct3.c deleted file mode 100644 index 6f627d2..0000000 --- a/functionproduct3.c +++ /dev/null @@ -1,22 +0,0 @@ -/*C program to product two numbers using functions -of type with arguments and return type*/ - -#include -int prod(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int mult=prod(a,b); - printf("Product of two numbers=%d",mult); -} - -int prod(int a,int b) -{ - int prod; - prod=a*b; - return prod; -} diff --git a/functionquadratic(1).c b/functionquadratic(1).c deleted file mode 100644 index 94c7ea8..0000000 --- a/functionquadratic(1).c +++ /dev/null @@ -1,39 +0,0 @@ -//C program to find roots of a quadratic equation using function. - -#include -#include -float roots(float a,float b,float c,float d,float r1,float r2); -void main() -{ - float a,b,c,d,r1,r2,quad; - printf("Enter coefficients of three integers:"); - scanf("%f%f%f",&a,&b,&c); - d=(b*b-4*a*c); - quad=roots(a,b,c,d,r1,r2); - if(quad==1) - { - printf("Roots are real and unequal"); - r1=(-b+sqrt(d))/(2*a); - r2=(-b+sqrt(d))/(2*a); - printf("r1=%f and r2=%f",r1,r2); - } - else if(quad==2) - { - printf("Roots are real and equal"); - r1=r2=(-b)/(2*a); - printf("r1=r2=%f",r1,r2);; - } - else - { - printf("Roots are imaginary and can not be found"); - } -} -float roots(float a,float b,float c,float d,float r1,float r2) -{ - if(d>0) - return 1; - else if(d==0) - return 2; - else - return 3; -} diff --git a/functionquadratic(2).c b/functionquadratic(2).c deleted file mode 100644 index c5d1893..0000000 --- a/functionquadratic(2).c +++ /dev/null @@ -1,39 +0,0 @@ -//C program to find roots of a quadratic equation using function. -// sampoorna -#include -#include -float roots(float a,float b,float c,float d,float r1,float r2); -void main() -{ - float a,b,c,d,r1,r2,quad; - printf("Enter coefficients of three integers:"); - scanf("%f%f%f",&a,&b,&c); - d=(b*b-4*a*c); - quad=roots(a,b,c,d,r1,r2); - if(quad==1) - { - printf("Roots are real and unequal"); - r1=(-b+sqrt(d))/(2*a); - r2=(-b+sqrt(d))/(2*a); - printf("r1=%f and r2=%f",r1,r2); - } - else if(quad==2) - { - printf("Roots are real and equal"); - r1=r2=(-b)/(2*a); - printf("r1=r2=%f",r1,r2);; - } - else - { - printf("Roots are imaginary and can not be found"); - } -} -float roots(float a,float b,float c,float d,float r1,float r2) -{ - if(d>0) - return 1; - else if(d==0) - return 2; - else - return 3; -} diff --git a/functionquadratic.c b/functionquadratic.c deleted file mode 100644 index 94c7ea8..0000000 --- a/functionquadratic.c +++ /dev/null @@ -1,39 +0,0 @@ -//C program to find roots of a quadratic equation using function. - -#include -#include -float roots(float a,float b,float c,float d,float r1,float r2); -void main() -{ - float a,b,c,d,r1,r2,quad; - printf("Enter coefficients of three integers:"); - scanf("%f%f%f",&a,&b,&c); - d=(b*b-4*a*c); - quad=roots(a,b,c,d,r1,r2); - if(quad==1) - { - printf("Roots are real and unequal"); - r1=(-b+sqrt(d))/(2*a); - r2=(-b+sqrt(d))/(2*a); - printf("r1=%f and r2=%f",r1,r2); - } - else if(quad==2) - { - printf("Roots are real and equal"); - r1=r2=(-b)/(2*a); - printf("r1=r2=%f",r1,r2);; - } - else - { - printf("Roots are imaginary and can not be found"); - } -} -float roots(float a,float b,float c,float d,float r1,float r2) -{ - if(d>0) - return 1; - else if(d==0) - return 2; - else - return 3; -} diff --git a/functionreverse(1).c b/functionreverse(1).c deleted file mode 100644 index 98f1c46..0000000 --- a/functionreverse(1).c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to reverse an inputted number using function. - -#include -int reverse(int num,int i,int rev); -void main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int result=reverse(num,i,rev); - printf("The reversed number=%d",result); -} -int reverse(int num,int i,int rev) -{ - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - return rev; -} diff --git a/functionreverse.c b/functionreverse.c deleted file mode 100644 index 98f1c46..0000000 --- a/functionreverse.c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to reverse an inputted number using function. - -#include -int reverse(int num,int i,int rev); -void main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int result=reverse(num,i,rev); - printf("The reversed number=%d",result); -} -int reverse(int num,int i,int rev) -{ - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - return rev; -} diff --git a/functionreverse1(1).c b/functionreverse1(1).c deleted file mode 100644 index 8673b67..0000000 --- a/functionreverse1(1).c +++ /dev/null @@ -1,23 +0,0 @@ -//C program to reverse an inputted number using function. - -#include -int reverse(int num,int rem,int rev); -void main() -{ - int num,rem,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=reverse(num,rem,rev); - printf("The reversed number=%d",res); - -} -int reverse(int num,int rem,int rev) -{ - while(num!=0) - { - rem=num%10; - rev=rev*10+rem; - num=num/10; - } - return rev; -} diff --git a/functionreverse1.c b/functionreverse1.c deleted file mode 100644 index 8673b67..0000000 --- a/functionreverse1.c +++ /dev/null @@ -1,23 +0,0 @@ -//C program to reverse an inputted number using function. - -#include -int reverse(int num,int rem,int rev); -void main() -{ - int num,rem,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - int res=reverse(num,rem,rev); - printf("The reversed number=%d",res); - -} -int reverse(int num,int rem,int rev) -{ - while(num!=0) - { - rem=num%10; - rev=rev*10+rem; - num=num/10; - } - return rev; -} diff --git a/functionseriessum.c b/functionseriessum.c deleted file mode 100644 index fe98e36..0000000 --- a/functionseriessum.c +++ /dev/null @@ -1,24 +0,0 @@ -/*C program to find sum of a series -9+99+999+9999+...... using function */ - -#include -int series(int,int,int,int); -void main() -{ - int i,n,sum=0,t=9; - printf("Enter no of terms:"); - scanf("%d",&n); - int res=series(i,n,sum,t); - printf("Sum of the series=%d\t",res); - -} -int series(int i,int n,int t,int sum) -{ - for(i=1;i<=n;i++) - { - sum+=t; - printf("%d ",t); - t=t*10+9; - } - return sum; -} diff --git a/functionsubtract(1).c b/functionsubtract(1).c deleted file mode 100644 index 66a4c1f..0000000 --- a/functionsubtract(1).c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to subtract two numbers using functions of -type with no arguments and no return type*/ - -#include -void subtract(); -void main() -{ - subtract(); -} -void subtract() -{ - int a,b,subtract; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - subtract=a-b; - printf("Subtraction of two numbers=%d",subtract); - -} diff --git a/functionsubtract.c b/functionsubtract.c deleted file mode 100644 index 66a4c1f..0000000 --- a/functionsubtract.c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to subtract two numbers using functions of -type with no arguments and no return type*/ - -#include -void subtract(); -void main() -{ - subtract(); -} -void subtract() -{ - int a,b,subtract; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - subtract=a-b; - printf("Subtraction of two numbers=%d",subtract); - -} diff --git a/functionsubtract1(1).c b/functionsubtract1(1).c deleted file mode 100644 index afa1d6b..0000000 --- a/functionsubtract1(1).c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to subtract two numbers using functions of -type with no arguments but return type*/ - -#include -int subtract(); -void main() -{ - int diff=subtract(); -} - -int subtract() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a-b); -} diff --git a/functionsubtract1.c b/functionsubtract1.c deleted file mode 100644 index afa1d6b..0000000 --- a/functionsubtract1.c +++ /dev/null @@ -1,19 +0,0 @@ -/*C program to subtract two numbers using functions of -type with no arguments but return type*/ - -#include -int subtract(); -void main() -{ - int diff=subtract(); -} - -int subtract() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - return(a-b); -} diff --git a/functionsubtract2(1).c b/functionsubtract2(1).c deleted file mode 100644 index 00391fd..0000000 --- a/functionsubtract2(1).c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to subtract two numbers using functions of -type with arguments but no return type*/ - -#include -void subtract(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - subtract(a,b); -} -void subtract(int a,int b) -{ - int diff; - diff=a-b; - printf("Subtraction of two numbers=%d",diff); -} diff --git a/functionsubtract2.c b/functionsubtract2.c deleted file mode 100644 index 00391fd..0000000 --- a/functionsubtract2.c +++ /dev/null @@ -1,20 +0,0 @@ -/*C program to subtract two numbers using functions of -type with arguments but no return type*/ - -#include -void subtract(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - subtract(a,b); -} -void subtract(int a,int b) -{ - int diff; - diff=a-b; - printf("Subtraction of two numbers=%d",diff); -} diff --git a/functionsubtract3(1).c b/functionsubtract3(1).c deleted file mode 100644 index c5ca7ce..0000000 --- a/functionsubtract3(1).c +++ /dev/null @@ -1,23 +0,0 @@ -/*C program to subtract two numbers using functions -of type with arguments and return type*/ - -#include -int subtract(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int diff=subtract(a,b); - printf("Subtraction of two numbers=%d",diff); - -} -int subtract(int a,int b) -{ - int diff; - diff=a-b; - return diff; - -} diff --git a/functionsubtract3.c b/functionsubtract3.c deleted file mode 100644 index c5ca7ce..0000000 --- a/functionsubtract3.c +++ /dev/null @@ -1,23 +0,0 @@ -/*C program to subtract two numbers using functions -of type with arguments and return type*/ - -#include -int subtract(int a,int b); -void main() -{ - int a,b; - printf("Enter first number:"); - scanf("%d",&a); - printf("Enter second number:"); - scanf("%d",&b); - int diff=subtract(a,b); - printf("Subtraction of two numbers=%d",diff); - -} -int subtract(int a,int b) -{ - int diff; - diff=a-b; - return diff; - -} diff --git a/functionsum100(1).c b/functionsum100(1).c deleted file mode 100644 index f8a3338..0000000 --- a/functionsum100(1).c +++ /dev/null @@ -1,18 +0,0 @@ -//C program to find sum of first 100 natural numbers using function. - -#include -int num(int i,int sum); -void main() -{ - int i,sum=0; - int add=num(sum,i); - printf("Sum of natural numbers=%d",add); -} -int num(int i,int sum) -{ - for(i=1;i<=100;i++) - { - sum=sum+i; - } - return sum; -} diff --git a/guessTheNumber.c b/guessTheNumber.c deleted file mode 100644 index 8ae4925..0000000 --- a/guessTheNumber.c +++ /dev/null @@ -1,32 +0,0 @@ -/*C program mini game for guessing number between 1 to 100*/ - -#include -#include -#include - -int main(){ - -srand(time(0)); -int num=rand()%100; -int n,count=1; -// printf("%d",num); - -do{ - printf("Enter you number\n"); - scanf("%d",&n); - - if(n>num){ - printf("Enter smaller number!!!!\n"); - - } - else if(n -int main() -{ - int a,b,x,y,t,hcf,lcm; - printf("Enter two integers:"); - scanf("%d%d",&x,&y); - a=x; - b=y; - while(b!=0) - { - t=b; - a=a%b; - a=t; - b--; - } - hcf=a; - lcm=(x*y)/hcf; - printf("The hcf of %d and %d = %d\n",x,y,hcf); - printf("The lcm of %d and %d = %d\n",x,y,lcm); -} diff --git a/ifelseLadder.c b/ifelseLadder.c deleted file mode 100644 index fa98d40..0000000 --- a/ifelseLadder.c +++ /dev/null @@ -1,25 +0,0 @@ -// Program to relate two integers using =, > or < symbol - -#include -int main() { - int number1, number2; - printf("Enter two integers: "); - scanf("%d %d", &number1, &number2); - - //checks if the two integers are equal. - if(number1 == number2) { - printf("Result: %d = %d",number1,number2); - } - - //checks if number1 is greater than number2. - else if (number1 > number2) { - printf("Result: %d > %d", number1, number2); - } - - //checks if both test expressions are false - else { - printf("Result: %d < %d",number1, number2); - } - - return 0; -} diff --git a/largestthree.c b/largestthree.c deleted file mode 100644 index c635247..0000000 --- a/largestthree.c +++ /dev/null @@ -1,28 +0,0 @@ -//C program to find largest number amongst three numbers. - -#include -int main() -{ - int n1,n2,n3; - printf("Enter three numbers:"); - scanf("%d%d%d",&n1,&n2,&n3); - if(n1>n2) - { - if(n1>n3) - { - printf("n1 is largest=%d",n1); - } - else - { - printf("n3 is largest=%d",n3); - } - } - if(n2>n3) - { - printf("n2 is largest=%d",n2); - } - else - { - printf("n3 is largest=%d",n3); - } -} diff --git a/largesttwo.c b/largesttwo.c deleted file mode 100644 index ada1246..0000000 --- a/largesttwo.c +++ /dev/null @@ -1,18 +0,0 @@ -//C program to find largest amongst two numbers. - -#include -int main() -{ - int n1,n2; - printf("Enter two numbers:"); - scanf("%d%d",&n1,&n2); - if(n1>n2) - { - printf("n1 is largest=%d",n1); - } - else - { - printf("n2 is largest=%d",n2); - } - return 0; -} diff --git a/mult.c b/mult.c deleted file mode 100644 index eb357e9..0000000 --- a/mult.c +++ /dev/null @@ -1,11 +0,0 @@ -//C program to multiply two numbers. - -#include -int main() -{ - int n1,n2,mult; //variable declaration - printf("Enter two numbers:"); - scanf("%d%d",&n1,&n2); - mult=n1*n2; - printf("Multiplication of two numbers=%d",mult); -} diff --git a/palindrome using c b/palindrome using c deleted file mode 100644 index df6790c..0000000 --- a/palindrome using c +++ /dev/null @@ -1,19 +0,0 @@ - #include - int main() - { - int n,r,sum=0,temp; - printf("enter the number="); - scanf("%d",&n); - temp=n; - while(n>0) - { - r=n%10; - sum=(sum*10)+r; - n=n/10; - } - if(temp==sum) - printf("palindrome number "); - else - printf("not palindrome"); - return 0; - } diff --git a/palindrome.c b/palindrome.c deleted file mode 100644 index 2136bea..0000000 --- a/palindrome.c +++ /dev/null @@ -1,22 +0,0 @@ -//C program to check a number whether it is palindrome or not. - -#include -int main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - if(rev==num) - { - printf("A palindrome number"); - } - else - { - printf("Not a palindrome number"); - } -} diff --git a/percentage.c b/percentage.c deleted file mode 100644 index 2d50040..0000000 --- a/percentage.c +++ /dev/null @@ -1,16 +0,0 @@ -//C program to display percentage of students in 5 subjects. - -#include -int main() -{ - int s1,s2,s3,s4,s5; - float sum,perc; - printf("Enter marks of 5 subjects:"); - scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5); - - sum=s1+s2+s3+s4+s5; - perc=(sum/500)*100; - - printf("Percentage of students in 5 subjects=%f",perc); - return 0; -} diff --git a/percentagealt.c b/percentagealt.c deleted file mode 100644 index 79ba77b..0000000 --- a/percentagealt.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -int main() -{ - int s,i,sum=0; - float perc; - printf("Enter marks of subjects:"); - scanf("%d",&s); - for(i=1;i<=5;i++) - { - sum=sum+s; - } - perc=(sum/500)*100; - printf("Percentage of students=%f",perc); - return 0; -} diff --git a/pointer.c b/pointer.c deleted file mode 100644 index 1172a69..0000000 --- a/pointer.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -void times(int *j) //Created a function times -{ - *j = pow(*j, 10); -} -int main() -{ - int i = 4, *j; - j = &i; - times(j); - printf("%d\n", i); - return 0; -} diff --git a/pointersToIntegers.c b/pointersToIntegers.c deleted file mode 100644 index 8e303cb..0000000 --- a/pointersToIntegers.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -int main(){ - - int x=10; - int* ptr; //Pointer to integer ptr declaration. - ptr = &x; //Assigning address of x to the pointer to integer ptr. - - printf("The value of x = %d\n", x); - - printf("The address of x in the memory is &x = %d\n", &x); - - printf("The address of x in the memory is ptr = %d\n", ptr); - - printf("The Hexadecimal address of x is ptr = %x\n", ptr); //The hexadecimal value is same as above - //integer value but it is in the Hexadecimal form. - printf("Dereferancing x by using *ptr = %d\n", *ptr); - - return 0; -} diff --git a/posnegative.c b/posnegative.c deleted file mode 100644 index bb903d6..0000000 --- a/posnegative.c +++ /dev/null @@ -1,22 +0,0 @@ -/*C program to check whether any inputted number is -negative,positive or zero.*/ - -#include -void main() -{ - int num; - printf("Enter a number:"); - scanf("%d",&num); - if(num<0) - { - printf("A negative number"); - } - else if(num>0) - { - printf("A positive number"); - } - else - { - printf("Zero"); - } -} diff --git a/prime.c b/prime.c deleted file mode 100644 index c5507b0..0000000 --- a/prime.c +++ /dev/null @@ -1,27 +0,0 @@ -//C program to check whether a number is prime or not. - -#include -int main() -{ - int num,i,count=1; - printf("Enter a number:"); - scanf("%d",&num); - for (int i = 2; i*i < n; i++) -{ - if (n%i==0) - { - isPrime = 0; - } -} - if (isPrime) -{ - printf ("The number %d is Prime\n", n); -} -else -{ - printf ("The number %d is not Prime \n", n); -} - -} - return 0; -} diff --git a/primeinrange.c b/primeinrange.c deleted file mode 100644 index a6ea431..0000000 --- a/primeinrange.c +++ /dev/null @@ -1,25 +0,0 @@ -//C program to print prime numbers between 1 to 100. - -#include -void main() -{ - int num,i,count; - printf("Prime numbers b/w 1 to 100:"); - - for(num=1;num<=100;num++) - { - count=0; - for(i=2;i=(num/2);i++) - { - if(num%i==0) - { - count++; - break; - } - } - if(count==0&&num!=1) - { - printf("%d",num); - } - } -} diff --git a/print50.c b/print50.c deleted file mode 100644 index 3057642..0000000 --- a/print50.c +++ /dev/null @@ -1,9 +0,0 @@ -//C program to print first 50 natural numbers. - -#include -int main() -{ int i; -for(i=1;i<=50;i++) - printf("%d\t",i); -} - diff --git a/printeven.c b/printeven.c deleted file mode 100644 index 34554e5..0000000 --- a/printeven.c +++ /dev/null @@ -1,8 +0,0 @@ -//C program to print only even numbers between 0 to 50. - -#include -int main() -{ int i; -for(i=2;i<=50;i+=2) - printf("%d\t",i); -} diff --git a/productdigits.c b/productdigits.c deleted file mode 100644 index 21feca8..0000000 --- a/productdigits.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to find product of digits of an inputted number. - -#include -int main() -{ - int n,prod=1,rem; - printf("Enter a number:"); - scanf("%d",&n); - - while(n!=0) - { - rem=n%10; - prod*=rem; - n=n/10; - } - printf("Product of digits in a number=%d",prod); -} diff --git a/quadratic.c b/quadratic.c deleted file mode 100644 index 1e8e153..0000000 --- a/quadratic.c +++ /dev/null @@ -1,28 +0,0 @@ -//C program to find roots of a quadratic equation. - -#include -void main() -{ - int a,b,c,d; - float r1,r2; - printf("Enter coefficients of three integers:"); - scanf("%d%d%d",&a,&b,&c); - d=b*b-4*a*c; - if(d<0) - { - printf("Roots are real and unequal"); - r1=(-b+sqrt(d))/(2*a); - r2=(-b-sqrt(d))/(2*a); - printf("r1=%f,r2=%f",r1,r2); - } - else if(d==0) - { - printf("Roots are real and equal"); - r1=r2=(-b)/(2*a); - printf("r1=%f,r2=%f",r1,r2); - } - else - { - printf("Roots are imaginary and can not be found"); - } -} diff --git a/reverse.c b/reverse.c deleted file mode 100644 index 71f4357..0000000 --- a/reverse.c +++ /dev/null @@ -1,15 +0,0 @@ -//C program to find reverse of an inputted number. - -#include -int main() -{ - int num,i,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - - for(i=num;i>0;i=i/10) - { - rev=rev*10+i%10; - } - printf("Reverse of a number=%d",rev); -} diff --git a/reversenatural.c b/reversenatural.c deleted file mode 100644 index 857a43d..0000000 --- a/reversenatural.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to print n natural numbers from 1 to n. - -#include -void main() -{ - int num,i; - printf("Enter a number:"); - scanf("%d",&num); - - for(i=num;i>0;i--) - { - printf("%d\n",i); - } -} diff --git a/reversewhile.c b/reversewhile.c deleted file mode 100644 index b63d53e..0000000 --- a/reversewhile.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to reverse an inputted number using while loop. - -#include -int main() -{ - int num,rem,rev=0; - printf("Enter a number:"); - scanf("%d",&num); - - while(num!=0) - { - rem=num%10; - rev=rev*10+rem; - num=num/10; - } - printf("Reverse of a number=%d",rev); -} diff --git a/seriessum.c b/seriessum.c deleted file mode 100644 index 49d8800..0000000 --- a/seriessum.c +++ /dev/null @@ -1,18 +0,0 @@ -//sampoorna -/*C program to find sum of the series -9+99+999+9999+...*/ - -#include -int main() -{ - int n,i,sum=0,t=9; - printf("Enter number of terms:"); - scanf("%d",&n); - for(i=1;i<=n;i++) - { - sum+=t; - printf("%d ",t); - t=t*10+9; - } - printf("Sum of the series=%d\n",sum); -} diff --git a/subjectsarray.c b/subjectsarray.c deleted file mode 100644 index 04eaa07..0000000 --- a/subjectsarray.c +++ /dev/null @@ -1,18 +0,0 @@ -//sampoorna -#include -void main() -{ - int sub[5],i,sum=0; - printf("Enter marks of 5 subjects:"); - for(i=0;i<=4;i++) - { - scanf("%d",&sub[i]); - sum=sum+sub[i]; - } - printf("Elements are\n"); - for(i=0;i<=4;i++) - { - printf("%d\t",sub[i]); - } - printf(" Sum is =%d",sum); -} diff --git a/subtract1array.c b/subtract1array.c deleted file mode 100644 index 8ca14a3..0000000 --- a/subtract1array.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -void main() -{ - int arr1[8],arr2[8],arr3[8],i; - printf("Enter 8 values in arr1:"); - for(i=0;i<=7;i++) - { - scanf("%d",&arr1[i]); - } - printf("Ente 8 values in arr2:"); - for(i=0;i<=7;i++) - { - scanf("%d",&arr2[i]); - } - for(i=0;i<=7;i++) - { - arr3[i]=arr1[i]-arr2[2]; - } - printf("Subtraction of two arrays:"); - for(i=0;i<=7;i++) - { - printf("%d",arr3[i]); - } -} diff --git a/subtractarray.c b/subtractarray.c deleted file mode 100644 index f3d685b..0000000 --- a/subtractarray.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -void main() -{ - int arr1[5],arr2[5],arr3[5],i; - printf("Enter 5 values in arr1:"); - for(i=0;i<=4;i++) - { - scanf("%d",&arr1[i]); - } - printf("Enter 5 values in arr2:"); - for(i=0;i<=4;i++) - { - scanf("%d",&arr2[i]); - } - for(i=0;i<=4;i++) - { - arr3[i]=arr1[i]*arr2[i]; - } - printf("Multiplication of two arrays"); - for(i=0;i<=4;i++) - { - printf("%d\t",&arr3[i]); - } -} diff --git a/sumeven.c b/sumeven.c deleted file mode 100644 index 2c3318e..0000000 --- a/sumeven.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to find sum of all even numbers from 1 to n. - -#include -int main() -{ - int n,i,sum=0; - printf("Enter a number:"); - scanf("%d",&n); - for(i=2;i<=n;i+=2) - { - sum=sum+i; - } - printf("Sum of all even numbers =%d",sum); -} diff --git a/sumnatural.c b/sumnatural.c deleted file mode 100644 index 8aa7609..0000000 --- a/sumnatural.c +++ /dev/null @@ -1,12 +0,0 @@ -//C program to find sum of first 100 natural numbers. - -#include -int main() -{ - int i,sum=0; - for(i=1;i<=100;i++) - { - sum=sum+i; - } - printf("Sum of first 100 natural numbers=%d",sum); -} diff --git a/sumodd.c b/sumodd.c deleted file mode 100644 index 91a7889..0000000 --- a/sumodd.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to sum of all odd numbers from 1 to n. - -#include -int main() -{ - int n,i,sum=0; - printf("Enter a number:"); - scanf("%d",&n); - for(i=1;i<=n;i+=2) - { - sum=sum+i; - } - printf("Sum of all odd numbers=%d",sum); -} diff --git a/sumofldfd.c b/sumofldfd.c deleted file mode 100644 index 16cec1b..0000000 --- a/sumofldfd.c +++ /dev/null @@ -1,20 +0,0 @@ -//C program to find sum of first and last digit of an inputted number. - -#include -int main() -{ - int num,i,fd,ld,sum=0; - printf("Enter a number:"); - scanf("%d",&num); - i=num; - ld=num%10; - - while(i>0) - { - if(i/10==0) - fd=i%10; - i=i/10; - } - sum=ld+fd; - printf("Sum of first and last digit of a number=%d",sum); -} diff --git a/swappedfirst&last.c b/swappedfirst&last.c deleted file mode 100644 index 07bf3a0..0000000 --- a/swappedfirst&last.c +++ /dev/null @@ -1,23 +0,0 @@ -//C program to swap the first and last digit of an inputted number. - -#include -int main() -{ - int num,i,fd,ld,t; - printf("Enter a number:"); - scanf("%d",&num); - i=num; - ld=num%10; - - while(i>0) - { - if(i/10==0) - fd=i%10; - i=i/10; - } - printf("The original values of ld=%d and fd=%d",ld,fd); - t=fd; - fd=ld; - ld=t; - printf("The swapped values of ld=%d and fd=%d",ld,fd); -} diff --git a/swapping.c b/swapping.c deleted file mode 100644 index cd35cd2..0000000 --- a/swapping.c +++ /dev/null @@ -1,14 +0,0 @@ -//C program to swap the values of two numbers. - -#include -int main() -{ - int x,y,t; - printf("Enter two numbers:"); - scanf("%d%d",&x,&y); - printf("The original values of x=%d and y=%d\n",x,y); - t=x; - x=y; - y=t; - printf("The swapped values of x=%d and y=%d",x,y); -} diff --git a/table.c b/table.c deleted file mode 100644 index e6a8f81..0000000 --- a/table.c +++ /dev/null @@ -1,13 +0,0 @@ -//C program to print multiplication table in desired format. - -#include -int main() -{ - int n,i; - printf("Enter a number for multiplication table:"); - scanf("%d",&n); - for(i=1;i<=10;i++) - { - printf("%d * %d = %d\n",n,i,n*i); - } -} diff --git a/table10num.c b/table10num.c deleted file mode 100644 index 9687294..0000000 --- a/table10num.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to print multiplication table of 10 numbers using nested loop. - -#include -int main() -{ - int i,j,num; - printf("Enter a number:\n"); - scanf("%d",&num); - printf("Table of 10 numbers\n"); - for(i=1;i<=10;i++) - { - for(j=1;j<=10;j++) - { - printf("%d\t",i*j); - } - } -} diff --git a/table2.c b/table2.c deleted file mode 100644 index fd80eff..0000000 --- a/table2.c +++ /dev/null @@ -1,13 +0,0 @@ -//C program to print multiplication table. - -#include -int main() -{ - int n,i; - printf("Enter a number for multiplication table:"); - scanf("%d",&n); - for(i=1;i<=10;i++) - { - printf("%d\n",n*i); - } -} diff --git a/vowel.c b/vowel.c deleted file mode 100644 index c7a5ba5..0000000 --- a/vowel.c +++ /dev/null @@ -1,17 +0,0 @@ -//C program to find a inputted character is vowel or consonant. - -#include -void main() -{ char c; - printf("Enter a character:"); - scanf("%c",&c); - if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U') - { - printf("A vowel"); - } - else - { - printf("A consonant"); - } - -} diff --git a/while50.c b/while50.c deleted file mode 100644 index 51fc777..0000000 --- a/while50.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -int main() -{ int i; -i=0; -while(i<=50) -{ - printf("%d\t",i); - i++; -} -} diff --git a/whileseries.c b/whileseries.c deleted file mode 100644 index 8c465ff..0000000 --- a/whileseries.c +++ /dev/null @@ -1,18 +0,0 @@ -//C program to find sum of series using while loop. - -#include -int main() -{ - int n,i,sum=0,t=9; - printf("Enter number of terms:"); - scanf("%d ",&n); - i=1; - while(i<=n) - { - sum+=t; - printf("%d",t); - t=t*10+9; - i++; - } - printf("Sum of the series=%d",sum); -} diff --git a/whileven.c b/whileven.c deleted file mode 100644 index 9eeac7f..0000000 --- a/whileven.c +++ /dev/null @@ -1,16 +0,0 @@ -//C program to print even numbers from 1 to 50 using while loop. - -#include -int main() -{ int i; -i=0; -while(i<=50) - { - if(i%2==0) - { - printf("%d\t",i); - } - i++; - - } -}