diff --git a/Linked_List.c b/Linked_List.c index ca92b99..c961cfb 100644 --- a/Linked_List.c +++ b/Linked_List.c @@ -1,124 +1,22 @@ -/*Write a C program that uses functions to perform the following: -a) Create a singly linked list of integers -b) Delete a given integer from the above linked list -c) Display the contents of the above list after deletion -CODE:-*/ -#include -#include +#include +#include + struct node { - int data; - struct node *next; + int data; + struct node* next; }; -struct node *head, *tail = NULL; -void addNode(int data) -{ - struct node *newNode=(struct node*)malloc(sizeof(struct node)); - newNode->data=data; - newNode->next=NULL; - if(head==NULL) - { - head=newNode; - tail=newNode; - } - else - { - tail->next = newNode; - tail = newNode; - } -} -void display() -{ - struct node *current = head; // the node current will point to head - if(head==NULL) - { - printf("List is empty\n"); - return; - } - printf("\nNodes of singly linked list: \n"); - while(current!= NULL) - { - printf("%d ", current->data); // each node is printed - current = current->next; - } - printf("\n"); -} -void delete() -{ - struct node *ptr,*ptr1; - int item,i=0,flag,loc,j; - ptr = head; - if(ptr == NULL) - { - printf("\nEmpty List\n"); - } - else - { - printf("\nWhich integer do you want to delete?\n"); - scanf("%d",&item); - while (ptr!=NULL) - { - if(ptr->data == item) - { - printf("Integer found at node %d ",i+1); - flag=0; - loc=i; - break; - } - else - { - flag=1; - } - i++; - ptr = ptr -> next; - } - if(flag==1) - { - printf("Integer not found!\n"); - } - } - ptr=head; - for(j=0;jnext; - if(ptr == NULL) - { - printf("\nDeletion is not possible!"); - return; - } - } - ptr1->next = ptr ->next; - free(ptr); - printf("\nDeleted node %d \n",loc+1); -} +typedef struct node NODE; + +//NODE head = NULL; + + +NODE *first, *second, *third; + int main() { - int n,m,data; - printf("How many nodes do you want to create?\n"); - scanf("%d",&n); - for(int i=0;i -void main() -{ float p,r,t,s; -printf("Enter the principal : "); -scanf("%f",&p); -printf("Enter the rate : "); -scanf("%f",&r); -printf("Enter the time : "); -scanf("%f",&t); -s=(p*r*t)/100; -printf("SI is %f",s); + +#include + +void main() { + float P, R, T, SI; + scanf("%f%f%f", & P, & R, & T); + SI = (P * R * T) / 100; + printf("%f", SI); + getch(); } diff --git a/a.out b/a.out new file mode 100755 index 0000000..27f32d5 Binary files /dev/null and b/a.out differ diff --git a/count_vowels b/count_vowels new file mode 100755 index 0000000..d415279 Binary files /dev/null and b/count_vowels differ diff --git a/count_vowels.c b/count_vowels.c new file mode 100644 index 0000000..64d5a2f --- /dev/null +++ b/count_vowels.c @@ -0,0 +1,26 @@ +#include + +// Program to count vowels in a string +int main() { + char str[100]; + int i, count = 0; + + // Ask the user to enter a string + printf("Enter a string: "); + fgets(str, sizeof(str), stdin); // safer input method than gets() + + // Loop through the string + for (i = 0; str[i] != '\0'; i++) { + // Check for both uppercase and lowercase vowels + if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || + str[i] == 'u' || str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || + str[i] == 'O' || str[i] == 'U') { + count++; + } + } + + // Display the total number of vowels + printf("Number of vowels: %d\n", count); + + return 0; +}