ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
How can u say that a given point is in a triangle?
1. with the co-ordinates of the 3 vertices specified.
2. with only the co-ordinates of the top vertex given.
 Question Submitted By :: Vadivel152
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.
Answer
# 1
solution for 1st case:
Given:(x1,y1),(x2,y2),(x3,y3),the co-ordinates of the
vertices of the triangle.
 Let (xx,yy) be the pt to be located.
 Find the equations of the lines {(x1,y1),(x2,y2)} and
{(x1,y1)(x3,y3)} using the formula 
((y-y1)/(y2-y1))=((x-x1)/(x2-x1))

 Now substitute the y value  in the 2 equations got. You 'll
be getting the x limits. If the given x value lies within
the limits you have found,the given pt is within the
triangle or else it is not.
 
Is This Answer Correct ?    3 Yes 0 No
Vadivel
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
void main() { int const * p=5; printf("%d",++(*p)); }  1
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }  1
Is the following code legal? typedef struct a { int x; aType *b; }aType  1
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution) Microsoft5
main() { extern int i; i=20; printf("%d",i); }  1
main() { char a[4]="HELL"; printf("%s",a); } Wipro1
main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; }  1
void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }  1
plz send me all data structure related programs  2
int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }  1
main() { int i=5,j=6,z; printf("%d",i+++j); }  1
void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }  1
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }  1
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft15
String reverse with time complexity of n/2 with out using temporary variable. NetApp8
Give a oneline C expression to test whether a number is a power of 2? Motorola16
main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }  1
main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }  1
char *someFun1() { char temp[ ] = “string"; return temp; } char *someFun2() { char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’}; return temp; } int main() { puts(someFun1()); puts(someFun2()); }  1
You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.  3
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com