Tuesday, 29 August 2017
Monday, 28 August 2017
Program To Check Whether A Number is Odd or Even.
#include<stdio.h>
void main()
{
int n;
clrscr();
printf("Enter the integer value\n");
scanf("%d",&n);
if(n%2==0)
printf("The value is even");
else
printf("The value is odd");
}
void main()
{
int n;
clrscr();
printf("Enter the integer value\n");
scanf("%d",&n);
if(n%2==0)
printf("The value is even");
else
printf("The value is odd");
}
Sunday, 27 August 2017
Program To Calculate Customers Telephone Bill
#include<stdio.h>
void main()
{
int units, custno;
float charge;
clrscr();
printf("Enter customer number and unit consumed\n");
scanf("%d%d",&custno,&units);
if(units<=200)
charge=0.5*units;
else if(units<=400)
charge=100+0.25*(units-200);
else if(units<=600)
charge=230+0.8*(units-400);
else
charge=390+(units-600);
printf("Customer no:%d consumed :%d units\n",custno,units);
printf("Total bill amount is : %.2f\n",charge);
}
void main()
{
int units, custno;
float charge;
clrscr();
printf("Enter customer number and unit consumed\n");
scanf("%d%d",&custno,&units);
if(units<=200)
charge=0.5*units;
else if(units<=400)
charge=100+0.25*(units-200);
else if(units<=600)
charge=230+0.8*(units-400);
else
charge=390+(units-600);
printf("Customer no:%d consumed :%d units\n",custno,units);
printf("Total bill amount is : %.2f\n",charge);
}
Sunday, 20 August 2017
Program to Perform all the Arithmetic Operations
#include<stdio.h>
main()
{
int first,second,Add,Sub,Mul;
float Div;
clrscr();
printf("Enter two integer numbers\n");
scanf("%d%d",&first,&second);
Add=first+second;
Sub=first-second;
Mul=first*second;
Div=first/second;
printf("Sum=%d\n",Add);
printf("Difference=%d\n",Sub);
printf("Multiplication=%d\n",Mul);
printf("Division=%f\n",Div);
return 0;
}
main()
{
int first,second,Add,Sub,Mul;
float Div;
clrscr();
printf("Enter two integer numbers\n");
scanf("%d%d",&first,&second);
Add=first+second;
Sub=first-second;
Mul=first*second;
Div=first/second;
printf("Sum=%d\n",Add);
printf("Difference=%d\n",Sub);
printf("Multiplication=%d\n",Mul);
printf("Division=%f\n",Div);
return 0;
}
Friday, 18 August 2017
Program to Calculate Simple Interest and Compound Interest
#include<stdio.h>
#include<math.h>
int main()
{
float p,q,r,smpi,cmpi;
int n;
clrscr();
printf("Enter the value of principle p = ");
scanf("%f",&p);
printf("Enter the value of rate r = ");
scanf("%f",&r);
printf("Enter the value of period in year n = ");
scanf("%d",&n);
smpi=((p*r*n)/100);
printf("The Simple Interest is=%f \n",smpi);
q=1+(r/100);
cmpi=p*pow(q,n)-p;
printf("The Compound Interest is=%f \n",cmpi);
return 0;
getch();
}
#include<math.h>
int main()
{
float p,q,r,smpi,cmpi;
int n;
clrscr();
printf("Enter the value of principle p = ");
scanf("%f",&p);
printf("Enter the value of rate r = ");
scanf("%f",&r);
printf("Enter the value of period in year n = ");
scanf("%d",&n);
smpi=((p*r*n)/100);
printf("The Simple Interest is=%f \n",smpi);
q=1+(r/100);
cmpi=p*pow(q,n)-p;
printf("The Compound Interest is=%f \n",cmpi);
return 0;
getch();
}
OUTPUT:-
Program To Perform Logical Operator
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter the value of a,b and c\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(b>c))
printf("\na is greater than b =%d",a);
else
printf("\nb is greater than a =%d",b);
if(a>c)
printf("\na is greater value than c =%d",a);
else
printf("\nc is greater value than a =%d",c);
if((a==b)||(a==c))
printf("\na value is equal to b");
else
printf("\nvalues are not equal");
getch();
}
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter the value of a,b and c\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(b>c))
printf("\na is greater than b =%d",a);
else
printf("\nb is greater than a =%d",b);
if(a>c)
printf("\na is greater value than c =%d",a);
else
printf("\nc is greater value than a =%d",c);
if((a==b)||(a==c))
printf("\na value is equal to b");
else
printf("\nvalues are not equal");
getch();
}
Program To Perform Relational Operator
#include<stdio.h>
#include<conio.h>
main()
{
int x,y,z;
clrscr();
printf("Enter the values of x,y and z\n");
scanf("%d%d%d,",&x,&y,&z);
if(x==y)
printf("\nBoth the values are same =%d",x,y);
if(x>y)
printf("\nThe value of x is greater =%d",x);
else
printf("\nThe value of y is greater =%d",y);
if(y!=z)
printf("\nThe value of y is not equal to =%d",y);
getch();
}
#include<conio.h>
main()
{
int x,y,z;
clrscr();
printf("Enter the values of x,y and z\n");
scanf("%d%d%d,",&x,&y,&z);
if(x==y)
printf("\nBoth the values are same =%d",x,y);
if(x>y)
printf("\nThe value of x is greater =%d",x);
else
printf("\nThe value of y is greater =%d",y);
if(y!=z)
printf("\nThe value of y is not equal to =%d",y);
getch();
}
Friday, 4 August 2017
SWAPPING OF TWO VALUES WITHOUT USING THIRD VARIABLE
#include<stdio.h>
#include<conio.h>
main()
{
int a=8, b=12;
clrscr();
printf("Before swap of two numbers a=%d b=%d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swap of numbers a=%d b=%d",a,b);
getch();
}
#include<conio.h>
main()
{
int a=8, b=12;
clrscr();
printf("Before swap of two numbers a=%d b=%d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("After swap of numbers a=%d b=%d",a,b);
getch();
}
Subscribe to:
Posts (Atom)
Write a program to draw a circle using mid-point circle drawing algorithm.
#include<iostream.h> #include<graphics.h> #include<conio.h> void drawcircle(int x0, int y0, int r) { ...
-
#include<iostream.h> #include<conio.h> #include<graphics.h> void drawCircle(int x, int y, int xc, int yc); void...
-
#include<stdio.h> #include<conio.h> main() { int a=8, b=12; clrscr(); printf("Before swap of two numbers a=%d b=%...
-
#include<stdio.h> main() { int num,i=1; printf("Enter the number whose multiple you want"); scanf("%d",...