Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CODE in C/Data Structures/delete_node.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include<stdio.h>
struct Node{
int val;
struct Node* next;

};
struct Node *newNode(int data){
struct Node *n = (struct Node *)malloc(sizeof(struct node *));
n->val = data;
n->next==NULL;
return n;
}
void insertAtTail(struct Node* head, int x){
if(head==NULL){
head = newNode(x);
return;
}
struct Node* temp=head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next=newNode(x);
return;
}
void deleteNode(struct Node* del){
if(del==NULL) return;
if(del->next==NULL) {
printf("Couldn't be deleted\n");
return;
}
struct Node* temp=del->next;
del->val = del->next->val;
del->next = del->next->next;
delete(temp);
return;
}
int main(){

}
13 changes: 13 additions & 0 deletions CODE in C/Mathematical/factorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<bits/stdc++.h>
using namespace std;
long long int fact(int n){
if(n==0) return 1;
return n*fact(n-1);
}
int main(){
int n;
cout<<"enter the number: ";
cin>>n;
if(n>=0) cout<<"Factorial of number is "<<fact(n)<<endl;
else cout<<"There is no factorial for negative numbers"<<endl;
}