Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Cells can be placed inside cells, creating complex nested structures to store in

ID: 3845035 • Letter: C

Question

Cells can be placed inside cells, creating complex nested structures to store information. Write a function celldepth(A, unused) that returns the depth of the input A (the second input unused should be part of your function definition, but it is not unused in calculation of the depth). Depth of a cell array is defined as the maximum of the depths of its contents plus 1. The depth of non-cell data is considered zero. You may assume that the input will not have a cell depth greater than 100.    In matlab
Example:

>> celldepth( {1 [2 3]}, 0 )
ans =
      1

>> celldepth( {1 {2 3}}, 0 )
ans =
      2

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
struct addr
{
   int houseno;
   char street[30];
   char city[20];
   char state[20];
};
struct emp
{
   int empno;
   char name[20];
   char desig[20];
   addr address;
   float basic;
}
void main()
{
   clrscr();

   emp evar[5];
   int i;
   char ch;

   for(i=0; i<5; i++)
   {
       cout<<"Employee No: ";
       cin>>evar[i].empno;
       cout<<"Employee Name: ";
       gets(evar[i].name);
       cout<<"Designation: ";
       gets(evar[i].desig);
       cout<<"House No: ";
       cin>>evar[i].address.houseno;
       cout<<"Street: ";
       gets(evar[i].address.street);
       cout<<"City: ";
       gets(evar[i].address.city);
       cout<<"State: ";
       gets(evar[i].address.state);
       cout<<"Basic Pay: ";
       cin>>evar[i].basic;
       cout<<" ";
   }
   clrscr();

   do
   {
       cout<<"Enter employee no. whose information is to be displayed: ";
       int eno;
       cin>>eno;
       int flag=0;
       for(i=0; i<5; i++)
       {
           if(evar[i].empno == eno)
           {
               flag = 1;
               cout<<" Employee Data: ";
               cout<<"Employee No: "<<evar[i].empno;
               cout<<" Name: "<<evar[i].name;
               cout<<" Designation: "<<evar[i].desig;
               cout<<" Address: "<<evar[i].address.houseno<<", ";
               cout<<evar[i].address.street<<", ";
               cout<<evar[i].address.city<<", ";
               cout<<evar[i].address.state<<endl;
               cout<<"Basic Pay: "<<evar[i].basic;
               cout<<" ";
               break;
           }
       }
       if(!flag)
       {
           cout<<" Sorry..!!..No such employee exists..!! ";
           cout<<"Exiting.....Press a key... ";
           getch();
           exit(1);
       }
       cout<<"Want to display more ? (y/n).. ";
       cin>>ch;
   }while(ch=='y' || ch=='Y');
   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote