Computer Science, asked by rohi17213it, 7 months ago

Vijay and Ruchi so much interested in gardening and hence she plants more trees in her garden. She plants trees in a rectangular fashion with the order of rows and columns and numbers the trees in a row-wise order. She planted the mango tree only in the 1st row, 1st column and last column. So, given the tree number, your task is to find out whether the given tree is a mango tree or not? Now, write a program to check whether the given number denotes a mango tree or not. INPUT FORMAT: Input consists of 3 integers. The first input denotes the number of rows. The second input denotes the number of columns. The third input denotes the tree number. OUTPUT FORMAT: If the given number is a mango tree, print "Yes". Otherwise, print "No" Refer the sample output for formatting. Answer:(penalty regime: 10, 20, ... %)

Answers

Answered by mishthy23
0

Answer: yes it can be a mango tree

Answered by beginnercode13
0

Answer:

#include<stdio.h>

#include<stdlib.h>

int main()

{

   int r,c,n,p=1,count=0,a[10][10];

   scanf("%d%d%d",&r,&c,&n);

   for(int i=1;i<=r;i++)

   {

       for(int j=1;j<=c;j++)

       {

           a[i][j]=p;

           p++;

       }

   }

   for(int i=1;i<=c;i++)

   {

       if(a[1][i]==n)

       {

           count++;

       }

   }

   for(int i=1;i<=r;i++)

   {

       if(a[i][1]==n)

       {

           count++;

       }

   }

   for(int i=1;i<=r;i++)

   {

       if(a[i][c]==n)

       {

           count++;

       }

   }

   if(count==1)

   {

       printf("Yes");

   }

   else

   {

       printf("No");

   }

}

Explanation:

Similar questions