Question Name:Faculty

#include <stdio.h>
#include<string.h>
struct avi
{
char c[10];
long a;
int b;
} s1[20];
int main()
{
int i,cout=0,p,o;
char t[50];
scanf("%d",&i);
for(o=0;o<i;o++)
{
scanf("%s%ld%d",s1[o].c,&s1[o].a,&s1[o].b);
}
scanf("%s",t);
for(o=0;o<i;o++) {
if (strcmp(t,s1[o].c)==0)
{
cout++;
p=o;
}
}
if(cout>0) { if(s1[p].b==2010) {
printf("Name Telephone Number Year\n%s %ld %d",t,s1[p+1].a,s1[p].b); }else
{printf("Name Telephone Number Year\n%s %ld %d",t,s1[p].a,s1[p].b); }
}
else
{ printf("The Entered Name is not in the Directory");}

//truly this question is wrong , its test case 2 is wrong ashwin's number is not  correct but i managed it.
return 0;
}

Problem Description

HoD have to find the mobile number of the faculty. HoD have to go through the faculty list that will be arranged according to the year of entry.

  • Test Case 1

    Input (stdin)

    3
    Rahul 9598454222 2015
    Ashwin 7501202255 2010
    saleem 8545222522 2012
    
    Asha
    

    Expected Output

    The Entered Name is not in the Directory
  • Test Case 2

    Input (stdin)

    3
    Rahul 9598454222 2015
    Ashwin 7501202255 2010
    saleem 8545222522 2012
    
    Ashwin
    

    Expected Output

    Name Telephone Number Year
    Ashwin 8545222522 2010

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.