Wednesday, April 4, 2012

Program


/* Problem1.7*/
#include<stdio.h>
#include<conio.h>
#define a 20
#define b 10
void main()
{
int c,d;
clrscr();
            c=a+b;
            d=a-b;
            printf("%d+%d=%d\n%d-%d=%d",a,b,c,a,b,d);
getch();
}
/* Problem1.8*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int a,b,c;
            float x;
            printf("Enter the value of a, b & c-\n");
            scanf("%d%d%d",&a,&b,&c);
            x=a/(b-c);
            printf("x=%f",x);
            getch();
}
/* Problem1.9(a)*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float c,f;
            printf("Enter the temparature in celsius=");
            scanf("%f",&c);
            f=(9*c/5)+32;
            printf("Temparature in fahrenheit=%5.2f",f);
            getch();
}
/* Problem1.9(b)*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float c,f;
            printf("Enter the temparature in fahrenheit=");
            scanf("%f",&f);
            c=5*(f-32)/9;
            printf("Temparature in celsius=%5.2f",c);
            getch();
}
/* Problem1.10*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
            clrscr();
            float a,b,c,S,A;
            printf("value of the sides of the triangle-\n");
            scanf("%f%f%f",&a,&b,&c);
            S=(a+b+c)/2;
            A=sqrt(S*(S-a)*(S-b)*(S-c));
            printf("Area of the triangle=%5.3f",A);
            getch();
}
/* Problem1.11*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
            clrscr();
            float D,x1,x2,y1,y2;
            scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
            D=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
            printf("D=%f",D);
            getch();
}
/* Problem1.12*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.1416
void main()
{
            clrscr();
            float a,p,r,x1=0,x2=4,y1=0,y2=5;
            r=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
            p=2*pi*r;
            a=pi*r*r;
            printf("Radius of the given circle=%f\n",r);
            printf("Perimeter of the given circle=%f\n",p);
            printf("Area of the given circle=%f\n",a);
            getch();
}
/* Problem1.13*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.1416
void main()
{
            clrscr();
            float a,d,x1=2,x2=5,y1=2,y2=6;
            d=sqrt(pow((x2-x1),2)+pow((y2-y1),2));
            a=pi*pow((d/2),2);
            printf("Diameter of the given circle=%5.2f\n",d);
            printf("Area of the given circle=%5.3f\n",a);
            getch();
}
/* Problem1.14*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int a=5,b=8,c=18;
            printf("%dx+%dy=%d",a,b,c);
            getch();
}
/* Problem1.15*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,b,c,d,x,y;
            scanf("%f%f",&x,&y);
            a=x+y;b=x-y;c=x*y;d=x/y;
            printf("sum=%f\ndifference=%f\nproduct=%f\ndivision=%f\n",a,b,c,d);
            getch();
}
/* Problem2.2*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float t,p;
            printf("Enter the amont of taka =");
            scanf("%f",&t);
            p=t*100;
            printf("%f paise.",p);
            getch();
}
/* Problem2.3*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int a,c;
            for(c=1;c<=100;c++)
            {
                        a=c%2;
                        if(a==0)
                        {
                                    printf("%d\t",c);
                        }
            }
            getch();
}
/* Problem2.4*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,b,c;
            printf("Give two decimal values.\n");
            scanf("%f%f",&a,&b);
            c=a/b;
            printf("The first number=%f\nThe second number=%f\nThe result=%f\n",a,b,c);
            getch();
}

/* Problem2.5*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,b;
            printf("price of the rice per kg=");scanf("%f",&a);
            printf("price of the sugar per kg=");scanf("%f",&b);
            printf("***LIST OF ITEMS***\nItem\tPrice\nRice\tRs %f\nSugar\tRs %f\n",a,b);
            getch();
}
/* Problem2.7*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int x,y;short int z;
            x=121314;
            y=121985;
            z=x+y;
            printf("x=%d\ty=%d\nz=%d",x,y,z);
            getch();
}
/* Problem2.8*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,b;int x;
            scanf("%f%f",&a,&b);
            x=a+b;
            printf("first number=%f\nsecond number=%f\nInteger sum of that two numbers=%d",a,b,x);
            getch();
}
/* Problem3.1*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int x,y,z,a,b,c,d;
            printf("x=");scanf("%d",&x);
            printf("y=");scanf("%d",&y);
            printf("z=");scanf("%d",&z);
            a=x+y+z;b=z+x;c=x+y;d=y+z;
            x=a-b;y=a-c;z=a-d;
            printf("x=%d\ty=%d\tz=%d\n",x,y,z);
            getch();
}
/* Problem3.2*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a;int b,s;
            scanf("%f",&a);
            s=a;
            b=s%10;
            printf("%d",b);
            getch();
}
/* Problem3.3*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a;int b,s;
            scanf("%f",&a);
            s=a;
            b=s%100;
            printf("%d",b);
            getch();
}
/* Problem3.4*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float l,w,a,p;
            printf("Length=");scanf("%f",&l);
            printf("Width=");scanf("%f",&w);
            a=l*w;
            p=2*(l+w);
            printf("Area of the rectangle=%2.2f\nPerimeter of the rectangle=%2.2f",a,p);
            getch();
}
/* Problem3.6*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,x,y,z;
            printf("Depreciation=");scanf("%f",&z);
            printf("Purchase price=");scanf("%f",&y);
            printf("Years of service=");scanf("%f",&x);
            a=y-(z*y);
            printf("Salvage value=%f",a);
            getch();
}
/* Problem3.7*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a;int b,c;
            printf("Give a number=");scanf("%f",&a);
            b=a+1;c=a-1;
            printf("\n\n%d\t%f\t%d\n",b,a,c);
            getch();
}
/* Problem3.8*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float s,u,a,t;
            scanf("%f",&u);
            scanf("%f",&a);
            scanf("%f",&t);
            s=(u*t)+((a*t*t)/2);
            printf("distance=%5.2f",s);
            getch();
}
/* Problem3.9*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
            clrscr();
            float EOQ,TBO,dr,sc,hc;
            printf("Demand rate=");scanf("%f",&dr);
            printf("Setup costs=");scanf("%f",&sc);
            printf("Holding cost per item per unit time=");scanf("%f",&hc);
            EOQ=sqrt((2*dr*sc)/hc);
            TBO=sqrt((2*sc)/(dr*hc));
            printf("Economic Order Quantity=%f\nTime Between Orders=%f",EOQ,TBO);
            getch();
}
/* Problem3.11*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int a,s;
            scanf("%4d",&a);
            s=(a%10)+((a/10)%10)+((a/100)%10)+(a/1000);
            printf("Sum of the numbers digits=%d",s);
            getch();
}
/* Problem3.12*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            printf("datatype\t    size(bits)\n");
            printf("char\t\t\t8\nunsigned char\t\t8\nint\t\t\t16\ninsigned int\t\t16\nshort int\t\t8\nunsigned short int\t8\nlong int\t\t32\nunsigned long int\t32\nfloat\t\t\t32\ndouble\t\t\t64\nlong double\t\t80\n");
            getch();
}
/* Problem3.13*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int a,b,c,x,y;
            printf("Enter three values-\n");
            scanf("%d%d%d",&a,&b,&c);
            x=(a>b)?a:b;
            y=(x>c)?x:c;
            printf("The largest value is %d",y);
            getch();
}
/* Problem3.14*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            int m,n,x;
            printf("m=");scanf("%d",&m);
            printf("n=");scanf("%d",&n);
            x=m%n;
            if(x==0)
            {
                        printf("%d is the multiple of %d",m,n);
            }
            else
            {
                        printf("%d is not the multiple of %d",m,n);
            }
            getch();
}
/* Problem3.15*/
#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            float a,b,c,x,y;
            printf("Enter the values-\n");scanf("%f%f%f",&a,&b,&c);
            x=a+b+c;printf("Sum of the values=%f\n",x);
            y=(a+b+c)/3;printf("Average of the values=%5.2f\n",y);
            if(a>b)
            {
                        if(a>c)
                        {
                                    printf("The largest number is %f\n",a);
                                    if(b>c)
                                    {
                                                printf("The smallest number is %f\n",c);
                                    }
                                    else
                                    {
                                                printf("The smallest number is %f\n",b);
                                    }
                        }
                        else
                        {
                                    printf("The largest number is %f\n",c);
                                    printf("The smallest number is %f\n",b);
                        }
            }
            else
            {
                        if(b>c)
                        {
                                    printf("The largest number is %f\n",b);
                                    if(a>c)
                                    {
                                                printf("The smallest number is %f\n",c);
                                    }
                                    else
                                    {
                                                printf("The smallest number is %f",a);
                                    }
                        }
                        else
                        {
                                    printf("The largest number is %f\n",c);
                                    printf("The smallest number is %f\n",a);
                        }
            }
            getch();
}
/* Problem3.17*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
            clrscr();
            int x;float a,b;
            printf("__________________________________________\n");
            printf("x(degrees)\tsin(x)\t\tcos(x)\n");
            for(x=0;x<=180;x=x+15)
            {
                        a=sin(x);
                        b=cos(x);
                        printf("%d\t\t%5.2f\t\t%5.2f\n",x,a,b);
            }
            printf("__________________________________________\n");
            getch();
}
/* Problem3.18*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
            clrscr();
            int a,b; float x;
            printf("_________________________________________________\n");
            printf("number\t\tsquare-root\t\tsquare\n");
            for(a=0;a<=100;a=a+10)
            {
                        x=sqrt(a);
                        b=a*a;
                        printf("%d\t\t%f\t\t%d\n",a,x,b);
            }
            printf("_________________________________________________\n");
            getch();
}
/* Problem1.5*/
#include<stdio.h>
#include<conio.h>
#define pi 3.1416
void main()
{
float r,area;
clrscr();                                                                                                           
            printf("Radius of the circle=");
            scanf("%f",&r);
            area=pi*r*r;
            printf("Area of the circle=%f\n",area);
getch();
}
/* Problem1.6*/
#include<stdio.h>
#include<conio.h>
void main()
{
            int a,c=1;
            clrscr();
            read:
            if(c<=10)
                        {
                        a=5*c;
                        printf("5*%d=%d\n",c,a);
                        goto read;
                        }
            else
                        {
                        printf(" ");
                        }
            getch();
}

No comments:

Post a Comment