#include <stdio.h>
#include <conio.h>
main()
{
int num;
clrscr();
printf("\n Enter any num to find absolute value");
scanf("\n %d",&num);
if(number<0)
{
num=(-1)*num;
printf("\n Absolute value is =%d",num);
}
return (0);
}
output:-
enter the value of num =-100
Absolute value
Welcome ! to C Language Extreme Programmings Blog through learn the programming complete examples.
Write a C program to check if all the three points fall on one straight line.
#include <stdio.h>
#include <conio.h>
main()
{
int x1,y1,x2,y2,x3,y3,x4,y4,slope1,slope2;
clrscr();
printf("\n Enter 1st co-ordinate (x1,y1)");
scanf("\n %d%d",&x1,&y1);
printf("\n Enter 2nd co-ordinate (x2,y2)");
scanf("\n %d%d",&x2,&y2);
printf("\n Enter 3rd co-ordinate (x3,y3)");
scanf("\n %d%d",&x3,&y3);
slope1=(y2-y1)/(x2-x1);
slope2=(y3-y2)/(x3-x2);
if(slope1==slope2)
{
printf("\n Three points fall on the same line");
}
else
{
printf("\nThree points doesn't fall on the same line");
}
return (0);
}
output:-
Enter 1st co-ordinate (x1,y1) =(1,1)
Enter 2nd co-ordinate (x2,y2) =(1,1)
Enter 3rd co-ordinate (x3,y3) =(1,1)
Three points fall on the same line
#include <conio.h>
main()
{
int x1,y1,x2,y2,x3,y3,x4,y4,slope1,slope2;
clrscr();
printf("\n Enter 1st co-ordinate (x1,y1)");
scanf("\n %d%d",&x1,&y1);
printf("\n Enter 2nd co-ordinate (x2,y2)");
scanf("\n %d%d",&x2,&y2);
printf("\n Enter 3rd co-ordinate (x3,y3)");
scanf("\n %d%d",&x3,&y3);
slope1=(y2-y1)/(x2-x1);
slope2=(y3-y2)/(x3-x2);
if(slope1==slope2)
{
printf("\n Three points fall on the same line");
}
else
{
printf("\nThree points doesn't fall on the same line");
}
return (0);
}
output:-
Enter 1st co-ordinate (x1,y1) =(1,1)
Enter 2nd co-ordinate (x2,y2) =(1,1)
Enter 3rd co-ordinate (x3,y3) =(1,1)
Three points fall on the same line
Write a c program to determine whether the seller profit or loss.
#include <stdio.h>
#include <conio.h>
main()
{
int cp,sp,total;
clrscr();
printf("\n enter cost price ");
scanf("\n %d",&cp);
printf("\n enter selling price");
scanf("\n %d",&sp);
total=sp-cp;
total=cp-sp;
if(total>0)
{
printf("\n total profit =%d",total);
}
else
{
if(total<0)
{
printf("\n total Loss =%d",total);
}
else
{
printf("\n neither total loss nor total profit");
}
}
return(0);
}
output:-
enter the cost price (cp) =100
enter the sell price (sp) =200
total profit =100
#include <conio.h>
main()
{
int cp,sp,total;
clrscr();
printf("\n enter cost price ");
scanf("\n %d",&cp);
printf("\n enter selling price");
scanf("\n %d",&sp);
total=sp-cp;
total=cp-sp;
if(total>0)
{
printf("\n total profit =%d",total);
}
else
{
if(total<0)
{
printf("\n total Loss =%d",total);
}
else
{
printf("\n neither total loss nor total profit");
}
}
return(0);
}
output:-
enter the cost price (cp) =100
enter the sell price (sp) =200
total profit =100
Subscribe to:
Posts (Atom)