TAB

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Tuesday 26 January 2016

PRACTICE PROBLEM 2 -(24-1 to 31-1) : SINGULAR TO PLURAL

#include<stdio.h>
#include<string.h>
int main()
{

char s[100];
char p[100];
scanf("%s",s);
int l=strlen(s);
char last=s[l-1];
char last_two[2];
last_two[0]=s[l-2];
last_two[1]=s[l-1];
int i;
for(i = 0; s[i]; i++){
    s[i] = tolower(s[i]);
    }
strcpy(p,s);
if(strcmp(last_two,"ch")==0 || strcmp(last_two,"sh")==0 || last=='s')
{
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
    }
   
else if(last=='y')
{
p[l-1]='i';
p[l]='e';
p[l+1]='s';
p[l+2]='\0';
    }
    else
    {
    p[l]='s';
}
printf("%s %s",s,p);
return 0;
}

9 comments:

  1. why are we not using & symbol for scanf statement?

    ReplyDelete
  2. Can you just explain why are you checking up==right?
    because the problem doesn't say that number of characters in row has to be equal to that of the no of characters in column

    ReplyDelete
  3. Please ask in the correct post to avoid confusion.

    The question says "the number of cells in the vertical and horizontal line of L shape is same".
    As I mentioned before this problem can be simply solve by checking if the cell above and to the right are same as the element itself. For THIS SPECIFIC PROBLEM it will suffice.

    ReplyDelete
    Replies
    1. i am extremely sorry for the inconvenience..
      But in skillrack its showing a infinite loop or time delay problem

      Delete
    2. and also in the example given the number of cells in the vertical and horizontal line of L shape is not same

      Delete
    3. Which problem are you referring to?

      Delete
    4. I have tried to explain it in the video linked.

      Delete
  4. sir what is ur e-mail id .i want to send u a code in wich i am facing .kindly help me.my e mail is deepak.khairwal2015@vit.ac.in

    ReplyDelete