1st about discount using if and logical operators
#include <stdio.h>
#include <conio.h>
void main()
{
int ppi;
int ib;
int tp;
int dis;
clrscr();
printf("price per item\n");
scanf("%d",&ppi);
printf("items bought\n");
scanf("%d",&ib);
tp=ppi*ib;
printf("total price =%d\n",tp);
if(ib>1&&ib<=15){
dis=tp-(tp*5)/100;
printf("discounted Price %d",dis);
}
if(ib>15&&ib<=100){
dis=tp-(tp*10)/100;
printf("discounted price %d\n",dis);
}
if(ib>100){
dis=tp-(tp*20)/100;
printf("discounted price is %d",dis);
}
getch();
}
2nd tax addition in electricity Bill
#include <stdio.h>
#include <conio.h>
void main()
{
int units;
int ppu;
int tp;
clrscr();
printf("enter total units\n");
scanf("%d",&units);
printf("enter price per unit\n");
scanf("%d",&ppu);
if(units>=300&&units<600){
tp=(ppu+5)*units;
printf("price after tax is %d",tp);
}
if(units>=600||(units<1500&&units>=600)){
tp=(ppu+10)*units;
printf("price after tax 10 per unit = %d",tp);
}
if(units>=1&&units<300){
tp=ppu*units;
printf("price is %d",tp);
}
getch();
}
3rd even odd functions
#include <stdio.h>
#include <conio.h>
void main()
{
int numa,numb;
clrscr();
printf("enter first number\n\n");
scanf("%d",&numa);
printf("enter 2nd number\n\n");
scanf("%d",&numb);
if(numa%2==0&&numb%2==0){
printf("sum both even is =%d\n\n",numa+numb);
}
if(numa%2==0&&numb%2!=0){
printf("subtraction ist is even 2nd is odd %d\n",numa-numb);
}
if(numa%2!=0&&numb%2==0){
printf("1st is odd 2nd is even %d\n",(numa*numb)*2);}
if(numa%2!=0&&numb%2!=0){
printf("multiply both are odd%d\n",numa*numb);
}
getch();
}
Finding Greatest Number of All
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b,c;
clrscr();
printf("\nEnter 3 numbers: ");
scanf("%d %d %d",&a,&b,&c);
if(a-b>0 && a-c>0)
printf("\nGreatest is a :%d",a);
else
if(b-c>0)
printf("\nGreatest is b :%d",b);
else
printf("\nGreatest is c :%d",c);
getch();
return 0;
}
#include <stdio.h>
#include <conio.h>
void main()
{
int ppi;
int ib;
int tp;
int dis;
clrscr();
printf("price per item\n");
scanf("%d",&ppi);
printf("items bought\n");
scanf("%d",&ib);
tp=ppi*ib;
printf("total price =%d\n",tp);
if(ib>1&&ib<=15){
dis=tp-(tp*5)/100;
printf("discounted Price %d",dis);
}
if(ib>15&&ib<=100){
dis=tp-(tp*10)/100;
printf("discounted price %d\n",dis);
}
if(ib>100){
dis=tp-(tp*20)/100;
printf("discounted price is %d",dis);
}
getch();
}
2nd tax addition in electricity Bill
#include <stdio.h>
#include <conio.h>
void main()
{
int units;
int ppu;
int tp;
clrscr();
printf("enter total units\n");
scanf("%d",&units);
printf("enter price per unit\n");
scanf("%d",&ppu);
if(units>=300&&units<600){
tp=(ppu+5)*units;
printf("price after tax is %d",tp);
}
if(units>=600||(units<1500&&units>=600)){
tp=(ppu+10)*units;
printf("price after tax 10 per unit = %d",tp);
}
if(units>=1&&units<300){
tp=ppu*units;
printf("price is %d",tp);
}
getch();
}
3rd even odd functions
#include <stdio.h>
#include <conio.h>
void main()
{
int numa,numb;
clrscr();
printf("enter first number\n\n");
scanf("%d",&numa);
printf("enter 2nd number\n\n");
scanf("%d",&numb);
if(numa%2==0&&numb%2==0){
printf("sum both even is =%d\n\n",numa+numb);
}
if(numa%2==0&&numb%2!=0){
printf("subtraction ist is even 2nd is odd %d\n",numa-numb);
}
if(numa%2!=0&&numb%2==0){
printf("1st is odd 2nd is even %d\n",(numa*numb)*2);}
if(numa%2!=0&&numb%2!=0){
printf("multiply both are odd%d\n",numa*numb);
}
getch();
}
Finding Greatest Number of All
#include <stdio.h>
#include <conio.h>
int main()
{
int a,b,c;
clrscr();
printf("\nEnter 3 numbers: ");
scanf("%d %d %d",&a,&b,&c);
if(a-b>0 && a-c>0)
printf("\nGreatest is a :%d",a);
else
if(b-c>0)
printf("\nGreatest is b :%d",b);
else
printf("\nGreatest is c :%d",c);
getch();
return 0;
}
No comments:
Post a Comment