├── a.exe ├── s.exe ├── main.exe ├── leastAppearInt.exe ├── s.c ├── first.cpp ├── pyramid.c ├── leastAppearInt.c ├── copy_array.c ├── check_anagram.c └── delete_middle_SingleLinkedList.c /a.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SID41214/Intro_C/HEAD/a.exe -------------------------------------------------------------------------------- /s.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SID41214/Intro_C/HEAD/s.exe -------------------------------------------------------------------------------- /main.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SID41214/Intro_C/HEAD/main.exe -------------------------------------------------------------------------------- /leastAppearInt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SID41214/Intro_C/HEAD/leastAppearInt.exe -------------------------------------------------------------------------------- /s.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void){ 5 | int num; 6 | printf("enter a number"); 7 | scanf("%d",&num); 8 | if (num<0){ 9 | printf("negative"); 10 | }else{ 11 | printf("positive"); 12 | } 13 | return EXIT_SUCCESS; 14 | } -------------------------------------------------------------------------------- /first.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | vector msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"}; 10 | 11 | for (const string& word : msg) 12 | { 13 | cout << word << " "; 14 | } 15 | cout << endl; 16 | } -------------------------------------------------------------------------------- /pyramid.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() 3 | { 4 | int i,j,spc,rows,k; 5 | printf("Input number of rows : "); 6 | scanf("%d",&rows); 7 | spc=rows+4-1; 8 | for(i=1;i<=rows;i++) 9 | { 10 | for(k=spc;k>=1;k--) 11 | { 12 | printf(" "); 13 | } 14 | 15 | for(j=1;j<=i;j++) 16 | printf("* "); 17 | printf("\n"); 18 | spc--; 19 | } 20 | } -------------------------------------------------------------------------------- /leastAppearInt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int ctr[101]; 4 | int num; 5 | 6 | int main() 7 | { 8 | int i,x,min_num,result; 9 | printf("What is the number of integers you wish to input? "); 10 | scanf("%d",&num); 11 | printf("Input the number(s):\n"); 12 | for(i=0;i0 && ctr[i] 2 | 3 | void main() 4 | { 5 | int arr1[100], arr2[100]; 6 | int i, n; 7 | 8 | 9 | printf("\n\nCopy the elements one array into another array :\n"); 10 | printf("----------------------------------------------------\n"); 11 | 12 | printf("Input the number of elements to be stored in the array :"); 13 | scanf("%d",&n); 14 | 15 | printf("Input %d elements in the array :\n",n); 16 | for(i=0;i 2 | #include 3 | #include 4 | 5 | //Two strings are anagram of each other, if we can rearrange 6 | //characters of one string to form another string. All the characters 7 | //of one string must be present in another string and should appear same 8 | //number of time in other string. Strings can contain any ASCII characters. 9 | //Example : rescued and secured, resign and singer, stone and tones, 10 | //pears and spare, ELEVEN PLUS TWO and TWELVE PLUS ONE 11 | 12 | 13 | int checkAnagram(char *str1, char *str2); 14 | int main() 15 | { 16 | char str1[100], str2[100]; 17 | printf("\n\n Function : whether two given strings are anagram :\n"); 18 | printf("\n\n Example : pears and spare, stone and tones :\n"); 19 | printf("-------------------------------------------------------\n"); 20 | printf(" Input the first String : "); 21 | fgets(str1, sizeof str1, stdin); 22 | printf(" Input the second String : "); 23 | fgets(str2, sizeof str2, stdin); 24 | 25 | if(checkAnagram(str1, str2) == 1) 26 | { 27 | str1[strlen(str1)-1] = '\0'; 28 | str2[strlen(str2)-1] = '\0'; 29 | printf(" %s and %s are Anagram.\n\n",str1,str2); 30 | } 31 | else 32 | { 33 | str1[strlen(str1)-1] = '\0'; 34 | str2[strlen(str2)-1] = '\0'; 35 | printf(" %s and %s are not Anagram.\n\n",str1,str2); 36 | } 37 | return 0; 38 | } 39 | 40 | //Function to check whether two passed strings are anagram or not 41 | int checkAnagram(char *str1, char *str2) 42 | { 43 | int str1ChrCtr[256] = {0}, str2ChrCtr[256] = {0}; 44 | int ctr; 45 | /* check the length of equality of Two Strings */ 46 | if(strlen(str1) != strlen(str2)) 47 | { 48 | return 0; 49 | } 50 | //count frequency of characters in str1 51 | for(ctr = 0; str1[ctr] != '\0'; ctr++) 52 | { 53 | str1ChrCtr[str1[ctr]]++; 54 | } 55 | //count frequency of characters in str2 56 | for(ctr = 0; str2[ctr] != '\0'; ctr++) 57 | { 58 | str2ChrCtr[str2[ctr]]++; 59 | } 60 | //compare character counts of both strings 61 | for(ctr = 0; ctr < 256; ctr++) 62 | { 63 | if(str1ChrCtr[ctr] != str2ChrCtr[ctr]) 64 | return 0; 65 | } 66 | return 1; 67 | } 68 | -------------------------------------------------------------------------------- /delete_middle_SingleLinkedList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct node 5 | { 6 | int num; //Data of the node 7 | struct node *nextptr; //Address of the node 8 | }*stnode; 9 | 10 | void createNodeList(int n); //function to create the list 11 | void MiddleNodeDeletion(int pos); //function to delete a node from middle 12 | void displayList(); //function to display the list 13 | 14 | int main() 15 | { 16 | int n,num,pos; 17 | printf("\n\n Linked List : Delete a node from the middle of Singly Linked List. :\n"); 18 | printf("-------------------------------------------------------------------------\n"); 19 | 20 | printf(" Input the number of nodes : "); 21 | scanf("%d", &n); 22 | createNodeList(n); 23 | 24 | printf("\n Data entered in the list are : \n"); 25 | displayList(); 26 | 27 | printf("\n Input the position of node to delete : "); 28 | scanf("%d", &pos); 29 | 30 | if(pos<=1 || pos>=n) 31 | { 32 | printf("\n Deletion can not be possible from that position.\n "); 33 | } 34 | if(pos>1 && pos num = num; 61 | stnode-> nextptr = NULL; //Links the address field to NULL 62 | tmp = stnode; 63 | 64 | //Creates n nodes and adds to linked list 65 | for(i=2; i<=n; i++) 66 | { 67 | fnNode = (struct node *)malloc(sizeof(struct node)); 68 | 69 | 70 | if(fnNode == NULL) //check whether the fnnode is NULL and if so no memory allocation 71 | { 72 | printf(" Memory can not be allocated."); 73 | break; 74 | } 75 | else 76 | { 77 | printf(" Input data for node %d : ", i); 78 | scanf(" %d", &num); 79 | 80 | fnNode->num = num; // links the num field of fnNode with num 81 | fnNode->nextptr = NULL; // links the address field of fnNode with NULL 82 | 83 | tmp->nextptr = fnNode; // links previous node i.e. tmp to the fnNode 84 | tmp = tmp->nextptr; 85 | } 86 | } 87 | } 88 | } 89 | 90 | void MiddleNodeDeletion(int pos) 91 | { 92 | int i; 93 | struct node *toDelMid, *preNode; 94 | 95 | if(stnode == NULL) 96 | { 97 | printf(" There are no nodes in the List."); 98 | } 99 | else 100 | { 101 | toDelMid = stnode; 102 | preNode = stnode; 103 | 104 | for(i=2; i<=pos; i++) 105 | { 106 | preNode = toDelMid; 107 | toDelMid = toDelMid->nextptr; 108 | 109 | if(toDelMid == NULL) 110 | break; 111 | } 112 | if(toDelMid != NULL) 113 | { 114 | if(toDelMid == stnode) 115 | stnode = stnode->nextptr; 116 | 117 | preNode->nextptr = toDelMid->nextptr; 118 | toDelMid->nextptr = NULL; 119 | free(toDelMid); 120 | } 121 | else 122 | { 123 | printf(" Deletion can not be possible from that position."); 124 | } 125 | } 126 | } 127 | 128 | void displayList() 129 | { 130 | struct node *tmp; 131 | if(stnode == NULL) 132 | { 133 | printf(" No data found in the list."); 134 | } 135 | else 136 | { 137 | tmp = stnode; 138 | while(tmp != NULL) 139 | { 140 | printf(" Data = %d\n", tmp->num); // prints the data of current node 141 | tmp = tmp->nextptr; // advances the position of current node 142 | } 143 | } 144 | } 145 | --------------------------------------------------------------------------------