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
84 changes: 42 additions & 42 deletions Appending_Node.c
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
#include<stdio.h>
#include<stdlib.h>
void append();
struct node
#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
int data;
struct node *link;
};
struct node *root;
} node;

node *append(node *);
void print(node *);

int main()
{
root=(struct node*)malloc(sizeof(struct node));
node *root=NULL;
node *current=NULL;
current = (node *)malloc(sizeof(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", &current->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", &current->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
current->link = NULL;
root = current; // this will store the address of the second node into the link part of the first node

printf("APPENDING NODE:\n");
append(); // now the user will be prompted for appending the element to the last of the linked list

root = append(root); // now the user will be prompted for appending the element to the last of the linked list
print(root);
return 0;
}

void append()
node *append(node *root)
{
struct node *temp;
temp=(struct node*)malloc(sizeof(struct node));
node *temp=NULL;
temp = (node *)malloc(sizeof(node));

printf("ENTER NODE DATA:");
scanf("%d", &temp->data);
temp->link = NULL;

if(root==NULL)
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
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)
node *ptr; // used for traversing through nodes
ptr = root;
while (ptr->link!= NULL)
{
ptr=ptr->link;
ptr = ptr->link;
}
ptr->link=temp; // this will connect the last node with the temp node which we created before
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);
return root;
}

void print(node *root)
{
node *ptr;
ptr = root;
printf("PRINTING DATA IN ALL NODES:\n");
while (ptr->link != NULL)
{
printf("%d->",ptr->data);
ptr = ptr->link;
}
printf("%d", ptr->data);
}
4 changes: 2 additions & 2 deletions Calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int main()
result=a/b;
printf("The Division Is %d", result);
break;
default:
printf("Please Enter a valid Operator");
default:
printf("Please Enter a valid Operator");
break;
}
return 0;
Expand Down
4 changes: 2 additions & 2 deletions Take input from user
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main()

// Performs all arithmetic operations
sum = no1 + no2;
sub = no - no2;
sub = no1 - no2;
mult = no1 * no2;
div = (float)no1 / no2;
mod = no1 % no2;
Expand All @@ -21,5 +21,5 @@ int main()
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
return 0;
}
10 changes: 5 additions & 5 deletions additionarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ int main()
{
int arr1[5],arr2[5],arr3[5],i;
printf("Enter 5 numbers of arr1:");
for(i=0;i<=4;i++)
for(i=0;i<5;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++)
for(i=0;i<5;i++)
{
scanf("%d",&arr2[i]);//Taking input from the user for the second array.
}
for(i=0;i<=4;i++)
for(i=0;i<5;i++)
{
arr3[i]=arr1[i]+arr2[i];//Addition of the two arrays.
}
printf("Addition of two array:");
for(i=0;i<=4;i++)
for(i=0;i<5;i++)
{
printf("%d\t",arr3[i]);//Printing the new array.
printf("%d ",arr3[i]);//Printing the new array.
}
}
4 changes: 2 additions & 2 deletions calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ int main()
result=a/b;
printf("The Division Is %d", result);
break;
default:
printf("Please Enter a valid Operator");
default:
printf("Please Enter a valid Operator");
break;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions difference.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ int main()
break;
default:
printf("Wrong Choice!!!");
break;
}
return 0;
}
26 changes: 13 additions & 13 deletions even.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//C program to find out a number is even or not.
// C program to find out a number is even or not.

#include<stdio.h>
#include <stdio.h>
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");
}

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");
}
}
3 changes: 2 additions & 1 deletion swapping.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//C program to swap the values of two numbers.

#include<stdio>
#include<stdio.h>
int main()
{
int x,y,t;
Expand All @@ -11,4 +11,5 @@ int main()
x=y;
y=t;
printf("The swapped values of x=%d and y=%d",x,y);
return 0;
}
1 change: 1 addition & 0 deletions table.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ int main()
{
printf("%d * %d = %d\n",n,i,n*i);
}
return 0;
}
4 changes: 2 additions & 2 deletions table10num.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
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);
}
printf("\n");
}
return 0;
}
1 change: 1 addition & 0 deletions table2.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ int main()
{
printf("%d\n",n*i);
}
return 0;
}