Skip to main content

Posts

Showing posts from July, 2016

WAP to enter three numbers and find middle number among them.

// WAP to enter three numbers and find middle number among them. #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( ( a > b && a < c ) || ( a > c && a < b ) ) printf ( "%d is middle number" , a ) ; else if ( ( b > a && b < c ) || ( b > c && b < a ) ) printf ( "%d is middle number" , b ) ; else printf ( "%d is middle number" , c ) ; getch ( ) ; } Output:

WAP to enter three numbers and find largest among them.

// WAP to enter three numbers and find largest among them.     #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( a > b && a > c ) printf ( "%d is largest" , a ) ; else if ( b > a && b > c ) printf ( "%d is largest" , b ) ; else printf ( "%d is largest" , c ) ; getch ( ) ; }  

WAP to check number is positive or negative.

// WAP to check number is positive or negative.     #include<stdio.h> #include<conio.h> void main ( ) { int x ; clrscr ( ) ; printf ( "Enter any number: \n " ) ; scanf ( "%d" ,& x ) ; if ( x > 0 ) printf ( "%d is positive number" , x ) ; else printf ( "%d is negative number" , x ) ; getch ( ) ; }  

WAP to check number is even or odd.

// WAP to check number is even or odd.     #include<stdio.h> #include<conio.h> void main ( ) { int x ; clrscr ( ) ; printf ( "Enter any number: \n " ) ; scanf ( "%d" ,& x ) ; if ( x % 2 == 0 ) printf ( "%d is even" , x ) ; else printf ( "%d is odd" , x ) ; getch ( ) ; }  

WAP to find the distance between two points (x1,y1) and (x2,y2).

// WAP to find the distance between two points (x1,y1) and (x2,y2). #include <stdio.h> #include <conio.h> #include <math.h> void main() { int x1,y1,x2,y2; float a=0,b=0,d=0; clrscr(); printf( "Enter x1:\n" ); scanf( "%d" ,&x1); printf( "Enter y1:\n" ); scanf( "%d" ,y1); printf( "Enter x2:\n" ); scanf( "%d" ,x2); printf( "Enter y2:\n" ); scanf( "%d" ,y2); a=x2-x1; b=y2-y1; d=sqrt(a*a+b*b); printf( "Distance = %f" ,a); getch(); }