if you want to remove an article from website contact us from top.

    write a menu driven program to perform the following operations

    Mohammed

    Guys, does anyone know the answer?

    get write a menu driven program to perform the following operations from screen.

    Write a menu driven Program to perform following operation.

    Home‎ > ‎BCA Projects‎ > ‎C Language Project sem 2 [F.Y.B.C.A.(2014-15)]‎ > ‎

    Write a menu driven Program to perform following operation.

    /*

    Write A Menu Driven Program To Perform Following Operation.

    1>      Copy one String To Onether String.

    2>      Reverse The String.

    3>      Join Two String Using UDF.

    #include

    */

    #include

    void func1(void); void func2(void); void func3(void); void main() { int     x,x1,x2,x3; select : clrscr(); printf("\n\tMenu");

    printf("\n----------------------------------------");

    printf("\n Select 1. For String Print Reverse.");

    printf("\n select 2. For String Copy.");

    printf("\n select 3. For Two String Join.");

    printf("\n----------------------------------------");

    printf("\nEnter Your Choice :- ");

    scanf("\n %d",&x); switch(x) { case 1 : { func1();

    printf("\n Select 1. For Restart.");

    printf("\n Select 2. For Exit");

    printf("\n\tEnter Your Choice :- ");

    scanf("%d",&x1); switch(x1) { case 1 : goto select ; case 2 : goto exit ; default :

    printf("\nYour Program Is Quit!");

    goto exit ; } goto select ; } case 2 : { func2();

    printf("\n Select 1. For Restart.");

    printf("\n Select 2. For Exit");

    printf("\n\tEnter Your Choice :- ");

    scanf("%d",&x2); switch(x2) { case 1 : goto select ; case 2 : goto exit ; default :

    printf("\nYour Program Is Quit!");

    goto exit ; } goto select ; } case 3 : { func3();

    printf("\n Select 1. For Restart.");

    printf("\n Select 2. For Exit");

    printf("\n\tEnter Your Choice :- ");

    scanf("%d",&x3); switch(x3) { case 1 : goto select ; case 2 : goto exit ; default :

    printf("\nYour Program Is Quit!");

    goto exit ; } goto select; } default : { goto select; } } exit : getch(); } void func1(void) {

    char   str[50],str1[50];

    int     i,l,j=0; fflush(stdin);

    printf("\nEnter Your String :- ");

    gets(str); l=0;

    while(str[l] != '\0')

    { l++; } for(i=l-1;i>=0;i--) { str1[j] = str[i]; j++; } str1[j]='\0';

    printf("\nYour Reverse String :- %s\n\n",str1);

    } void func2(void) {

    char   str[50],str1[50];

    int     i,l,j=0; fflush(stdin);

    printf("\nEnter Your String :- ");

    gets(str); l=0;

    while(str[l] != '\0')

    for(i=0;i

    { l++; }

    { str1[j] = str[i]; j++; } str1[j]='\0';

    printf("\nYour Copy String :- %s\n\n",str1);

    } void func3(void) {

    char   str[50],str1[50];

    int     i,l,j; fflush(stdin);

    printf("\nEnter Your First String :- ");

    gets(str); fflush(stdin);

    printf("\nEnter You Second String :- ");

    gets(str1); l=0;

    while(str[l] != '\0')

    { l++; } j=l; for(i=0;i<=l;i++) { str[j] = str1[i]; j++; } str[j]='\0';

    printf("\nYour Concate String :- %s\n\n",str);

    } Output:

    ----------------------------------------

    Select 1. For String Print Reverse.

    select 2. For String Copy.

    select 3. For Two String Join.

    ----------------------------------------

    Enter Your Choice :- 1

    Enter Your String :- Vrushabh

    Your Reverse String :- hbahsurV

    Select 1. For Restart.

    Select 2. For Exit

    Enter Your Choice :- 1

    Menu

    ----------------------------------------

    Select 1. For String Print Reverse.

    select 2. For String Copy.

    select 3. For Two String Join.

    ----------------------------------------

    Enter Your Choice :- 2

    Enter Your String :- Vrushabh

    Your Copy String :- Vrushabh

    Select 1. For Restart.

    Select 2. For Exit

    Enter Your Choice :- 1

    Menu

    ----------------------------------------

    Select 1. For String Print Reverse.

    select 2. For String Copy.

    select 3. For Two String Join.

    ----------------------------------------

    Enter Your Choice :- 3

    Enter Your First String :- Vrushabh

    EMter You Second String :- Ranpariya

    Your Concate String :- VrushabhRanpariya

    Select 1. For Restart.

    Select 2. For Exit

    Enter Your Choice :- 2

    Comments

    स्रोत : sites.google.com

    Write a menu

    Write a menu-driven program to perform following Matrix operations (2-D array implementation): 8 a) Sum b) Difference c) Product d) Transpose - q21s1.cpp

    Instantly share code, notes, and snippets.

    singalhimanshu/q21s1.cpp

    Created Star

    Write a menu-driven program to perform following Matrix operations (2-D array implementation): 8 a) Sum b) Difference c) Product d) Transpose

    Raw

    q21s1.cpp #include

    using namespace std;

    bool checka(int x, int y, int m, int n){

    if((x==m)&&(y==n)) return true; else return false }

    bool checkp(int i, int j, int l, int m){

    if(j==l){ return true; } else{ return false; } }

    void add(int **a, int **b, int r, int c){

    int **arr = new int *[r];

    for(int i =0; i

    arr[i] = new int[c];

    for(int j=0; j

    }

    for(int k=0; k

    arr[j][k] = a[j][k] + b[j][k];

    cout<

    } } }

    void sub(int **a, int **b, int r, int c){

    int **arr = new int *[r];

    for(int i =0; i

    arr[i] = new int[c];

    for(int j=0; j

    }

    for(int k=0; k

    arr[j][k] = a[j][k] - b[j][k];

    cout<

    } } }

    void multiplication(int **a, int **b, int r1, int c1, int r2, int c2){

    int **arr = new int *[r1];

    for(int l=0; i

    arr[l] = new int[c2];

    for(int i=0; i

    }

    for(int j=0; jfor(int k=0; k

    arr[i][j] += a[i][k] * b[k][j];

    cout<

    } } } }

    void transpose(int *a, int r, int c){

    int **arr = new int *[c];

    for(int i=0; i

    arr[i] = new int[r];

    for(int j=0; j

    }

    for(int k=0; k

    arr[j][k] = arr[j][k];

    cout<

    } } } int main(){ int r1, c1, r2, c2

    cout<<"Enter the no of rows of 1st matrix";

    cin>>r1;

    cout<<"Enter the no of col of 1st matrix";

    cin>>c1;

    int **a = new int *[r1];

    for(int i=0; i

    a[i] = new int[c1]; }

    cout<<"Enter the no of rows of 2nd matrix";

    cin>>r2;

    cout<<"Enter the no of col of 2nd matrix";

    cin>>c2;

    int **b = new int *[r2];

    for(int j=0; j

    b[j] = new int[c2]; }

    cout<<"Enter the elements of the first matrix";

    for(int k=0; kfor(int l=0; l

    cin>>a[k][l]; } cout<<"\n"; }

    cout<<"Enter the elements of the second matrix";

    for(int m=0; mfor(int n=0; ncout<<"1.Addition\n2.Subtraction\n3.Multiplication\n4.Transpose\n0.Exit"<

    cin>>a[m][n]; } cout<<"\n"; } do{

    cout<<"Enter your choice:";

    cin>>opt; switch(opt){ case 1:

    if((checka(r1,c1,r2,c2))==true){

    add(a,b,r1,c1); } else{ break; } break; case 2:

    if((checka(r1,c1,r2,c2))==true){

    sub(a,b,r1,c1); } else{ break; } break; case 3:

    if((checkp(r1,c1,r2,c2))==true){

    multiplication(a,b,r1,c1,r2,c2);

    } else{ break; } break; case 4: int x;

    cout<<"Which matrix do you want to transpose 1st or 2nd";

    cin>>x; if(x==1){

    transpose(a,r1,c1); //transpose of the 1st matrix

    } else if(x==2){

    transpose(b,r2,c2); //transpose of the 2nd matrix;

    } break; case 0: break; default:

    cout<<"Wrong choice try again";

    } }while(opt!=0) return 0; }

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    स्रोत : gist.github.com

    Menu driven program for all operations on singly linked list in C

    A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

    Menu driven program for all operations on singly linked list in C

    Difficulty Level : Easy

    Last Updated : 03 Jul, 2022

    Read Discuss Practice Video Courses

    A Linked List is a linear data structure that consists of two parts: one is the data part and the other is the address part. In this article, all the common operations of a singly linked list is discussed in one menu-driven program.

    Operations to be performed:createList(): To create the list with ‘n’ number of nodes initially as defined by the user.traverse(): To see the contents of the linked list, it is necessary to traverse the given linked list. The given traverse() function traverses and prints the content of the linked list.insertAtFront(): This function simply inserts an element at the front/beginning of the linked list.insertAtEnd(): This function inserts an element at the end of the linked list.insertAtPosition(): This function inserts an element at a specified position in the linked list.deleteFirst(): This function simply deletes an element from the front/beginning of the linked list.deleteEnd(): This function simply deletes an element from the end of the linked list.deletePosition(): This function deletes an element from a specified position in the linked list.maximum(): This function finds the maximum element in a linked list.mean(): This function finds the mean of the elements in a linked list.sort(): This function sort the given linked list in ascending order.reverseLL(): This function reverses the given linked list.

    Below is the implementation of the above operations:

    C

    // C program for the all operations in

    // the Singly Linked List

    #include #include

    // Linked List Node struct node { int info; struct node* link; };

    struct node* start = NULL;

    // Function to create list with n nodes initially

    void createList() {

    if (start == NULL) {

    int n;

    printf("\nEnter the number of nodes: ");

    scanf("%d", &n); if (n != 0) { int data;

    struct node* newnode;

    struct node* temp;

    newnode = malloc(sizeof(struct node));

    start = newnode; temp = start;

    printf("\nEnter number to"

    " be inserted : "); scanf("%d", &data); start->info = data;

    for (int i = 2; i <= n; i++) {

    newnode = malloc(sizeof(struct node));

    temp->link = newnode;

    printf("\nEnter number to"

    " be inserted : "); scanf("%d", &data);

    newnode->info = data;

    temp = temp->link; } }

    printf("\nThe list is created\n");

    } else

    printf("\nThe list is already created\n");

    }

    // Function to traverse the linked list

    void traverse() { struct node* temp; // List is empty if (start == NULL)

    printf("\nList is empty\n");

    // Else print the LL

    else { temp = start;

    while (temp != NULL) {

    printf("Data = %d\n", temp->info);

    temp = temp->link; } } }

    // Function to insert at the front

    // of the linked list

    void insertAtFront()

    { int data; struct node* temp;

    temp = malloc(sizeof(struct node));

    printf("\nEnter number to"

    " be inserted : "); scanf("%d", &data); temp->info = data;

    // Pointer of temp will be

    // assigned to start

    temp->link = start; start = temp; }

    // Function to insert at the end of

    // the linked list void insertAtEnd() { int data;

    struct node *temp, *head;

    temp = malloc(sizeof(struct node));

    // Enter the number

    printf("\nEnter number to"

    " be inserted : "); scanf("%d", &data); // Changes links temp->link = 0; temp->info = data; head = start;

    while (head->link != NULL) {

    head = head->link; } head->link = temp; }

    // Function to insert at any specified

    // position in the linked list

    void insertAtPosition()

    {

    struct node *temp, *newnode;

    int pos, data, i = 1;

    newnode = malloc(sizeof(struct node));

    // Enter the position and data

    printf("\nEnter position and data :");

    scanf("%d %d", &pos, &data);

    // Change Links temp = start;

    newnode->info = data;

    newnode->link = 0;

    while (i < pos - 1) {

    temp = temp->link; i++; }

    newnode->link = temp->link;

    temp->link = newnode;

    }

    // Function to delete from the front

    // of the linked list

    void deleteFirst() { struct node* temp; if (start == NULL)

    printf("\nList is empty\n");

    else { temp = start;

    start = start->link;

    free(temp); } }

    // Function to delete from the end

    // of the linked list

    void deleteEnd() {

    struct node *temp, *prevnode;

    if (start == NULL)

    printf("\nList is Empty\n");

    else { temp = start;

    while (temp->link != 0) {

    स्रोत : www.geeksforgeeks.org

    Do you want to see answer or more ?
    Mohammed 8 day ago
    4

    Guys, does anyone know the answer?

    Click For Answer