Created
June 16, 2016 05:46
-
-
Save Jeffrey-Kimani/ac897aab563abe23ed5dcb7caa31fa38 to your computer and use it in GitHub Desktop.
Linked List
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> | |
<component name="CidrRootsConfiguration"> | |
<sourceRoots /> | |
<libraryRoots /> | |
<excludeRoots /> | |
</component> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/ProgramsClass.iml" filepath="$PROJECT_DIR$/.idea/ProgramsClass.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="CPP_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$"> | |
<sourceFolder url="file://$MODULE_DIR$/DynamicMemmory.c" isTestSource="false" /> | |
<sourceFolder url="file://$MODULE_DIR$/CMakeLists.txt" isTestSource="false" /> | |
</content> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
<orderEntry type="module-library"> | |
<library name="Header Search Paths"> | |
<CLASSES> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/lib/gcc/mingw32/4.8.1/include-fixed" /> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/lib/gcc/mingw32/4.8.1/include" /> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/include" /> | |
</CLASSES> | |
<SOURCES> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/lib/gcc/mingw32/4.8.1/include-fixed" /> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/lib/gcc/mingw32/4.8.1/include" /> | |
<root url="file://C:/Program Files (x86)/CodeBlocks/MinGW/include" /> | |
</SOURCES> | |
</library> | |
</orderEntry> | |
</component> | |
</module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.5) | |
project(ProgramsClass) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
set(SOURCE_FILES LinkedList.c) | |
add_executable(ProgramsClass ${SOURCE_FILES}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Gosling-James on 6/16/2016. | |
// | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int no, *pt,i; | |
printf("Enter no of Students :"); | |
scanf("%d",&no); | |
pt=(int *)malloc(no*sizeof(int)); //allocate enough memory space | |
if(pt== NULL) | |
{ | |
printf("\n\nMemory allocation failed!\n"); | |
exit(0); | |
} | |
printf("Size allocated %i bytes\n",no*sizeof(int)); | |
printf("The base address is %d in decimal\n\n", pt); | |
printf("Enter students' roll no\n"); | |
for (i=0;i<no;i++) | |
{ | |
printf("Enter number "); | |
scanf("%d",(pt+i)); //advance 4 bytes to the right | |
} | |
printf("* Entered numbers are. *\n"); | |
for (i=0;i<no;i++) | |
{ //Display the address and its content | |
printf("Number in address %d-->%d\n",(pt+i), *(pt+i)); | |
} | |
free(pt); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Gosling-James on 6/16 | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct LinkedList | |
{ | |
int data; | |
struct LinkedList* next; | |
}; | |
int main() | |
{ | |
struct LinkedList* node1=NULL; | |
struct LinkedList* node2=NULL; | |
struct LinkedList* node3=NULL; | |
struct LinkedList* node4=NULL; | |
struct LinkedList* node5=NULL; | |
node1 = malloc(sizeof(struct LinkedList)); | |
node2 = malloc(sizeof(struct LinkedList)); | |
node3 = malloc(sizeof(struct LinkedList)); | |
node4 = malloc(sizeof(struct LinkedList)); | |
node5 = malloc(sizeof(struct LinkedList)); | |
node1->data = 100; | |
node1->next = node2; | |
node2->data = 400; | |
node2->next = node3; | |
node3->data = 320; | |
node3->next = node4; | |
node4->data = 12; | |
node4->next = node5; | |
node5->data = 56; | |
node5->next = NULL; | |
while(node1!=NULL) | |
{ | |
printf("The Node has data %d\n",node1->data); | |
node1 = node1->next; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment