Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is the Time and space complexity of given code

#include<stdio.h>
#include<stdlib.h>
struct details
{
     char name[30];
     int eid;
     char bg;
     int pn;
}emp[5];
void emp_search(int r)
{
     int id,i;
     printf("\nEnter Employee-Id to be Searched : ");
     scanf("%d",&id);
     printf("----------------------------------------\n");
     for(i=0;i<r;i++)
     {
          if(emp[i].eid==id)
          {
               printf("Employee Id : %d",emp[i].eid);
               printf("\nName        : %s",emp[i].name);
               printf("\nblood grp     : %s\n",emp[i].bg);
               printf("\nphone number     : %d\n",emp[i].pn);
          }
     }
}
void display(int r)
{
     int i;
     printf("\nList of All Employees:\n");
     printf("-------------------------------\n");
     printf("Emp-Id\tEmp-Name  bg\n");
     printf("--------------------------------\n");
     for(i=0;i<r;i++)
     {
          printf("%d\t%s\t%s\t %d\n",emp[i].eid,emp[i].name,emp[i].bg,emp[i].pn);
     }
}
void blood_grp(int r)
{
     int i;
     printf("\nblood group is o\n");
     printf("------------------------------------------------");
     for(i=0;i<r;i++)
     {
          if(emp[i].bg=='o')
          {
               printf("\n Employee Name : %s",emp[i].name);
               printf("\n Employee-Id   : %d",emp[i].eid);
               printf("\n blood grp        : %s\n",emp[i].bg);
               printf("\n phone number        : %d\n",emp[i].pn);
          }
     }
}
int main()
{
     int n,i,ch;
     printf("/*How Many Employee Record You Want to Add*/\n\nEnter Limit  : ");
     scanf("\n %d",&n);
     for(i=0;i<n;i++)
     {
          printf("-----------------------------------------");
          printf("\n\tEnter Details of Employee-%d",i+1);
          printf("\n-----------------------------------------");
          printf("\nName of Employee : ");
          scanf("%s",emp[i].name);
          printf("Employee-Id      : ");
          scanf("%d",&emp[i].eid);
          printf("blood grp : ");
          scanf("%s",&emp[i].bg);
          printf("phone number : ");
          scanf("%d",&emp[i].pn);
     }
     while(1)
     {
          printf("-----------------------------------------\n");
          printf("\t\tMenu\n");
          printf("-----------------------------------------");
          printf("\n 1:Search Employee by E-ID");
          printf("\n 2:List of All Employee");
          printf("\n 3:blood group is o");
          printf("\n 4:Exit");
          printf("\n----------------------------------------\n");
          printf("Enter Your Choice : ");
          scanf("\n %d",&ch);
          switch(ch)
          {
               case 1: emp_search(n);
               break;
               case 2: display(n);
               break;
               case 3: blood_grp(n);
               break;
               case 4: exit(0);
          }
     }
     return 0;
}


What I have tried:

I tried but I not got the answer please help me.
Posted
Updated 23-Jun-21 20:48pm
Comments
Member 15226818 23-Jun-21 21:39pm    
Can you explain your question please?

Working out the Big O notation[^] for code is your assignment, not ours - and while we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 
You need to understand time complexity and Algorithmic Complexity to understand and solve your taskand provide the solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900