Posts

Showing posts from August, 2023

data structure assignment2-setB-Q2:sort strings in ascending order

 Data structure using c: 2) Write a ‘C’ program to accept names from the user and sort in alphabetical order using bubble sort answer: #include <stdio.h> #include <stdlib.h> #include <string.h> #define l 6   void display(char array[][30]){   for(int i=0; i<l; i++){     printf("%s ", array[i]);   }   printf("\n");    printf("\n"); }   int main() {     char array[l][30];       printf("Enter %d Strings: \n", l);   for(int i=0; i<l; i++){     scanf("%s", array[i]);   }       printf("Original array: ");   display(array);     char temp[30];       for(int i=0; i<l; i++){     for(int j=0; j<l-1-i; j++){       if(strcmp(array[j], array[j+1]) > 0){            ...

data structure assignment1 practice program1

 1) Write a menu driven C program to perform the following operation on an integer array:  a) Display the sum of elements at even subscript position of array . b) Display the sum of elements at odd subscript position of array. answer: #include <stdio.h> #include <conio.h> int main() {     int a[10], i, n;     int choice, sum = 0;     printf("\n enter array limit:");     scanf("%d", &n);     printf("\n enter array elements:");     for (i = 0; i < n; i++)     {         scanf("%d", &a[i]);     }     printf("\n 1.sum of all even index element of an array.\n");     printf("\n 2.sum of all odd index element of an array.\n");     printf("\n.................................................!");     printf("\n enter your ...