C Code 29 _ To find the Position of a person diametrically Opposite on a circle [Wipro Programming Question]



C Code 29 _ To find the Position of a person diametrically Opposite on a circle  [Wipro Programming Question]




Program:


#include<stdio.h>
int main()
{
                int n,pos,opp;
                printf("\nEnter the number of persons in the circle (Enter only even numbers) : ");
                scanf("%d",&n);
                if(n%2==0)
                {
                                printf("\nEnter the position of person from 1 to %d to find the opposite person to him on the circle : ",n);
                                scanf("%d",&pos);
                                if(pos<=n&&pos>0)
                                {
                                                if(pos>(n/2))
                                                {
                                                                opp=pos-(n/2);
                                                }
                                                else
                                                {
                                                                opp=pos+(n/2);
                                                }
                                                printf("\nThe person opposite to %d is %d",pos,opp);
                                }
                                else
                                {
                                                printf("\nEnter position from 1 to %d only",n);
                                }
                }
                else
                {
                                printf("\nEnter only even numbers");
                }
                return 0;
}




Output:














Thank You ...

Popular Posts