Wednesday, 10 March 2010


Chapter – 1

1.1
#include
#include

void main()
{
   clrscr();
   printf("\n Name= Al  Maraj ");
   printf("\n Id  = 09105044         ");
   printf("\n Prog= BSEEE                     ");
   getch();
}

1.2
/*Border line to the address*/
#include
#include
void main()
{
   clrscr();
   printf("**************************");
   printf("\n* Name= Al Maraj*");
   printf("\n* Id  = 09105044         *");
   printf("\n* Prog= BSEEE                   *");
   printf("\n**************************");
   getch();
}

1.3
#include
void main()
{
clrscr();
printf("*");
printf("\n* *");
printf("\n* * *");
printf("\n* * * *");
getch();
}





1.4
/*Write a program using suitable characters*/
#include
#include

void main()
{
                clrscr();
                printf(" ----                         ----\n");
                printf("|    |                        |    |\n");
                printf("|    |>>------->|    |    | \n");
                printf("|    |                        |    |\n");
                printf(" ----                         ----\n");
                getch();
}

1.5
/*Area of circle,Define the pi*/
#include
#include
#define pi 3.1416

void main()
{
                float A,r;
                clrscr();
                printf("Enter the value of r=       ");
                scanf("%f",&r);
                A=(pi*(r*r));
                printf("Area=     %f",A);
                getch();
}



1.6
/*Multiplication table*/
#include
#include

void main()
{
                clrscr();
                printf("\t\t5*1=5");
                printf("\n\t 5*2=10");
                printf("\n\t 5*3=15");
                printf("\n\t  .   .");
                printf("\n\t  .   .");
                printf("\n\t 5*10=50");
                getch();
}


1.7
/*add two number and sub two number*/
#include
#include

void main()
{
                int a,b,c,d;
                clrscr();
                a=20;
                b=10;
                c=a+b;
                d=a-b;
                printf("\n20+10=%d",c);
                printf("\n20-10=%d",d);
                getch();
}

1.8
#include
#include
void main()
{
                int a,b,c;
                float x;
                clrscr();
                scanf("%d%d%d",&a,&b,&c);
                x=(a/(b-c));
                printf("%f",x);
                getch();
}

1.9(A)
/*F to C*/
#include
#include

void main()
{
                float f,c;
                clrscr();
                printf("Enter the Celsius:");
                scanf("%f",&c);
                f=((9*c)/5)+32;
                printf("Fahrenheit:%f",f);
                getch();
}

1.9(B)
/*C to F*/
#include
#include

void main()
{
                float f,c;
                clrscr();
                printf("Enter the Fahrenheit:");
                scanf("%f",&f);
                c=(((f-32)*5)/9);
                printf("Celsius:%f",c);
                getch();
}

1.10
/*A=sqrt(S*(S-a)*(S-b)*(S-c))*/
#include
#include
#include

void main()
{
                int a,b,c;
                float S,A;
                clrscr();
                scanf("%d%d%d",&a,&b,&c);
                S=((a+b+c)/2);
                printf("%f",S);
                A=sqrt(S*(S-a)*(S-b)*(S-c));
                printf("\n%f",A);
                getch();
}

1.11
/*Deference two points*/
#include
#include
#include

void main()
{
                int x1,y1,x2,y2;
                float D;
                clrscr();
                scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
                D=sqrt((x2-x1)^2+(y2-y1)^2);
                printf("%f",D);
                getch();
}

1.12
/*Area of circle*/
#include
#include
#include

void main()
{
                int x1,y1,x2,y2;
                float d,perimeter,area;
                clrscr();
                scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
                d=sqrt((x2-x1)^2+(y2-y1)^2);
                printf("D=%f",d);
                perimeter=(2*3.1416*(d/2));
                printf("\nPerimeter=%f",perimeter);
                area=(3.1416*d*d);
                printf("\nArea=%f",area);
                getch();
}

1.13
/*Area of Circle*/
#include
#include
#include

void main()
{
                int x1,y1,x2,y2;
                float D,Area,r;
                clrscr();
                scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
                D=sqrt((x2-x1)^2+(y2-y1)^2);
                printf("D=%f",D);
                r=(D/2);
                Area=(3.1416*r*r);
                printf("\nArea=%f",Area);
                getch();
}

1.14
#include
#include
#include

void main()
{
                int a,b,c,x,y;
                clrscr();
                x=2;
                y=1;
                printf("Enter the value a and b:");
                scanf("%d%d",&a,&b);
                c=(a*x)+(b*y);
                printf("C=ax+by\n =%d",c);
                getch();
}

1.15
#include
#include
#include

void main()
{
                int x,y,sum,difference,product;
                float division;
                clrscr();
                printf("x=");
                scanf("%d",&x);
                printf("y=");
                scanf("%d",&y);
                sum=x+y;
                difference=x-y;
                product=x*y;
                division=(float)(x)/(float)(y);
                printf("sum=                      %d",sum);
                printf("\nDifference=    %d",difference);
                printf("\nProduct=          %d",product);
                printf("\nDivision=         %f",division);
                getch();
}

Chapter – 2

2.1
#include
#include
#include
void main()
{
                int a,n,b;
                float sum;
                clrscr();
                sum=0;
                printf(" n= ");
                scanf("%d",&n);
                {
                                for(a=1;a<=n;a++)
                                sum=sum+(1/(float)(a));
                }
                printf("\n\n       Sum= %f",sum);
                getch();
}

2.2

#include
#include

void main()
{
                float a;
                int b;
                clrscr();
                printf(" Enter the price= ");
                scanf("%f",&a);
                b=(int)(a*100);
                printf("\n\n       Result= %d",b);
                getch();
}

2.3
#include
#include

void main()
{
                int count;
                clrscr();
                printf(" Even number :\n");
                for(count=1;count<=100;count++)
                {
                                if(!(count%2))
                                printf("\t%d",count);
                }
                getch();
}

2.4
#include
#include

void main()
{
                float a,b,c;
                clrscr();
                printf(" Enter the first number = ");
                scanf("%f",&a);
                printf("\n            Enter the second number = ");
                scanf("%f",&b);
                c=(b/a);
                printf("\n\n       Result= %f",c);
                getch();
}

2.5
#include
#include

void main()
{
                clrscr();
                printf(" *** LIST OF ITEMS ***\n\n");
                printf(" Item \t Price\n");
                printf(" Rice \t Rs 16.75\n");
                printf(" Sugar \t Rs 15.00");
                getch();
}

2.6
#include
#include

void main()
{
                int a,b,c;
                clrscr();
                printf("\n            Imput negative number= ");
                scanf("%d",&a);
                printf("\n            Imput positive number= ");
                scanf("%d",&b);
                printf("\n            Set= ");
                if(a<=0)
                {
                                for(c=a;c<=b;c++)
                                printf("\t%d",c);
                }
                getch();
}

2.7
#include
#include

void main()
{
                int x,y;
                short int z;
                clrscr();
                printf("\n            x=");
                scanf("%d",&x);
                printf("\n            y=");
                scanf("%d",&y);
                z=((short int)(x))+((short int)(y));
                printf("\n\n       z= %d",z);
                getch();
}

2.8
#include
#include

void main()
{
                float a,b;
                int c;
                clrscr();
                printf("Enter the first number=");
                scanf("%f",&a);
                printf("\nEnter the srcond number=");
                scanf("%f",&b);
                c=a+b;
                printf("\n\nSum=  %d",c);
                getch();
}

2.9
#include
#include

#define pi 3.1416

void main()
{
                typedef int roll;
                float r,area,p;
                clrscr();
                //printf("\n        Roll        =              ");
                //scanf("%c",&roll);
                printf("\n            Enter the Redius=");
                scanf("%f",&r);
                area=(pi*(r*r));
                printf("\n\n       Area=  %f",area);
                getch();
}



Chapter – 3

3.1
#include
void main()
{
int a,b,c;
a=5;
b=12;
c=10;
printf(“\t a=%d”,b);
printf(“\n\t b=%d”,c);
printf(“\n\t c=%d”,a);
}

3.2

#include


void main()

{

float a;

int b;

printf("Enter the floating point number=");

scanf("%f",&a);

b=a*100;

printf("Display the integer Number= %d",b);

}




3.3


3.4



3.5


3.6


3.7


3.8


3.9

3.10

3.11

Chapter 5

5.1         Determine Odd & even

#include
#include

void main()
{
            int n;
            clrscr();
            printf("Enter the number=");
            scanf("%d",&n);
            if(n%2==0)
                        printf("NUMBER IS EVEN");
                        else
                        printf("NUMBER IS ODD");
            getch();
}

5.2             Find the number and sum of 100>number>200 that are divisible by 7.
#include
#include

void main()
{
            int a,sum;
            clrscr();
            sum=0;
            for(a=100;a<=200;a++)
            {
                        if(a%7==0)
                        printf("\t%d\n",a);
                        sum=sum+a;
            }
            printf("\nThe result=%d",sum);
            getch();
}

5.3     Find x1 & x2
A set of two liner equation with two unknowns x1 and x2 is given below:


ax1+bx2=m
cx1+dx2=n
The set has a unique solution



#include
#include

void main()
{
            int a,b,c,d,m,n;
            float x1,x2;
            clrscr();
            printf("Enter the four values=");
            scanf("%d%d%d%d",&a,&b,&c,&d);
            if(!(a*d-c*b)==0)
            {
                        x1=((m*d-b*n)/(a*d-c*b));
                        x2=((n*a-m*c)/(a*d-c*b));
                        printf("Result of x1 and x2=%f\t%f",x1,x2);
            }
            getch();
}

5.4      0<=mark<=100
                Given a list of  marks  ranging  from  0 to 100, write a program to compute and  print  the  number  of  student.


(a)    Who have obtained more than 80 marks
(b)   Who have obtained more than 60 marks
(c)    Who have obtained more than 40 marks
(d)   Who have obtained 40 or less marks
(e)    In the range 81 to 100
(f)     In the range 61 to 80
(g)    In the range 41 to 60
(h)    In the range 0 to 40



#include
#include

void main()
{
      int mark;
      clrscr();
      printf("Enter your marks=");
      scanf("%d",&mark);
      if(mark<=100&&mark>=81)
      {
                  printf("\nmore than 80 mark");
      }
      else if(mark<=80&&mark>=61)
      {
                  printf("\nmore than 60 mark");
      }
      else if(mark<=60&&mark>=41)
      {
                  printf("\nmore than 40 mark");
      }
      else
      {
                  printf("\nless than 40 mark");
      }
      getch();
}

5.5     Admission to a professional  course  is subject to the  flowing condition



(a)    Marks in mathematics>=60
(b)   Marks in physics>=50
(c)    Marks in Chemistry>=40
(d)   Total in all three subject>=200
Or
Total in mathematics and physics>=150



#include
#include

void main ()
{
      int math,phy,che,total,mp;
      clrscr();
      printf ("\nInput  your  math  numbert=");
      scanf ("%d",&math);
      printf ("\nInput  your physics numbert=");
      scanf ("%d",&phy);
      printf ("\nInput  your chemistry numbert=");
      scanf ("%d",&che);
      total=(math+physics+chemistry);
      mp=math+phy;
      printf ("mp=%d\n",mp);
      printf ("total=%d",total);
      if (math>=60 && phy>=50 && che>=40 && total>=200||mp>=150)
      {
                   printf ("\n ok");
      }
      else
      {
                   printf ("\n not ok");
      }
      getch();
}

5.6          Write a program to print a two dimensional square root table as shown below, to provide the   square root of 0 to 9.9. For example, the value x will give the square root of 3.2 and y the square root of 3.9.

#include
#include
#include

void main()
{
            float a,b,c,k,sum;
            clrscr();
            for(a=0;a<=9;a++)
            {
                        for(b=0;b<=9;b++)
                        {
                                    c=a*1;
                                    k=b/10;
                                    sum=sqrt(c+k);
                                    printf("%-3.2f\t",sum);
                        }
                        printf("\n");
            }
            getch();
}

5.7      Shown below is a Floyd’s triangle.
1
2 3
4 5 6
…………
……………..
79……………91

#include
#include

void main()
{
            int a,b,c;
            clrscr();
            c=1;
            for(a=1;a<=5;a++)
            {
                        printf("\n");
                        for(b=1;b<=a;b++)
                        {
                        printf("%d\t",c);
                        c=c+1;
                        }
            }
            getch();
}

5.8    A cloth showroom has announced the following seasonal discounts on purchase of items:
Purchase
Discount
Amount
Mill Cloth
Hand loon items
0 – 100
--
5%
101 – 200
5%
7.5%
201 – 300
7.5%
10.0%
Above 300
10.0%
15.0%

#include
#include
#include

void main ()
{
            int am,mi,ha,tomi,toha;
            clrscr();
            printf("Enter your ammount:");
            scanf ("%d",&am);
            if (am>0 && am<=100)
            {
                        mi=(0);
                        ha=((am*5)/100);
            }
            else if(am>101 && am<=200)
            {
                        mi=((am*5)/100);
                        ha=((am*7.5)/100);
            }
            else if(am>201 && am<=300)
            {
                        mi=((am*7.5)/100);
                        ha=((am*10.0)/100);
            }
            else if(am>301)
            {
                        mi=((am*10.0)/100);
                        ha=((am*15.0)/100);
            }
            printf("Discount Mill cloth=%d",mi);
            printf("\nDiscount Handloon items=%d",ha);
            tomi=am-mi;
            toha=am-ha;
            printf("\nTotal Mill cloth=%d",tomi);
            printf("\nTotal Handloon items=%d",toha);
            getch();
}

5.9           Write a program that will read the value of x and evaluate the following function.
 1         for x<0
Y= {     0         for x=0
-1          for x>0

#include
#include

void main()
{
            int x,y;
            clrscr();
            scanf("%d",&x);
            if(x>0)
            {
                        printf("\ny=1\n");
            }
            else if(x==0)
            {
                        printf("y=0\n");
            }
            else if(x<0)
            {
                        printf("\ny=-1");
            }
            getch();
}

5.10                      Write a program to compute the real roots of quadratic equation.
                The root are given by the equation
                                               
                                               
The following rule:
(a)    No solution, if both a and b are zero
(b)   There is only one root, if a=0 (x=-c/b)
(c)    There are no real roots, if  is negative
(d)   Otherwise, there are two real roots

#include
#include

void main()
{
            int a,b,c,d;
            float x,x1,x2;
            clrscr();
            printf("Enter the number a,b and c=");
            scanf("%d%d%d",&a,&b,&c);
            d=b*b-4*a*c;
            if(a==0&&b==0)
            {
                        printf("\nNo solution.");
            }
            else if(a==0)
            {
                        x=((float)(-c))/((float)(b));
                        printf("if a=0,there are only one root.\n x=%f",x);
            }
            else if(d<=0)
            {
                        printf("There are no real roots.");
            }
            else
            {
                        x1=-b+(sqrt(d)/(2*a));
                        x2=-b-(sqrt(d)/(2*a));
                        printf("\nX1=%f",x1);
                        printf("\nX2=%f",x2);
            }
            getch();
}

5.11                      Write a program to read three integer values from the keyboard and displays the output stating that they are the sides of right angled triangle.

#include
#include

void main()
{
            int x,y,z,f;
            clrscr();
            printf("Enter the value of height:");
            scanf("%d",&x);
            printf("Enter the value of base:");
            scanf("%d",&y);
            printf("Enter the value of hypotenuse:");
            scanf("%d",&z);
            f=((x*x)+(y*y));
            if(f==(z*z))
            {
                        printf("It is a right angle triangle");
            }
            else
            {
                        printf("It is not a right angle triangle ");
            }
            getch();
}

5.12                      An electricity board charges  the following rates for the  use of  electricity:
For the 1st 200 units: 80 P per unit
For the 2nd 100 units: 90 P per unit
Beyond 300 units: 1.00 P per unit
All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400, then an addition surcharge of 15% of a total amount is charge.

#include
#include
#include
void main()
{
            float unit,a,b,c,total,d;
            clrscr();
            printf("Enter your useing unit=");
            scanf("%f",&unit);
            if(unit<=200)
            {
                        a=unit*0.80;
                        printf("Charge=%8.2f",a);
            }
            else if(unit>=201 && unit<=300)
            {
                        c=unit-200;
                        a=(c*0.90)+((unit-c)*.80);
                        printf("Charge=%8.2f",a);
            }
            else if(unit>=301)
            {
                        b=unit-300;
                        c=unit-(200+b);
                        a=(b*1.00)+(c*0.90)+((unit-(b+c))*0.80);
                        printf("Charge=%8.2f",a);
            }
            printf("\nMinimum Meter charge Rs.100.\n");
            total=a+100;
            printf("Total ammount with meter charge\t:%8.2f",total);
            printf("\nIf amountis more than Rs.400.");
            if(total>400)
            {
                        d=total+((total*15)/100);
                        printf("\t:%8.2f",d);
            }
            else
            {
                        printf("\t:%8.2f",total);
            }
            getch();
}

5.13                      Write a program to compute and display the sum of integers that are divisible by 6 but not divisible by 4 and lie between 0 and 100. The program should also count and display the number of such values.

#include
#include

void main()
{
            int a,sum;
            clrscr();
            for(a=0;a<=100;a++)
            {
                        if((a%6==0) && (a%4!=0))
                        printf("0 to 100 : %d\n",a);
                        sum=sum+a;
            }
            printf("Sum=%d",sum);
            getch();
}

5.14                      Write an interactive program   that could read a positive integer number and decide whether the number is a prime number and display the output accordingly. Modify the program to count all the prime numbers that lie between 100 and 200.

 #include
#include
#include

void main()
{
            int a,b;
            clrscr();
            printf("Range 100 to 200:\n");
            for(a=100;a<=200;a++)
            {
                        for(b=2;b<=200;b++)
                        if(a%b==0)
                        {
                                    break;
                        }
                        if(a==b)
                                    printf("%d\t",a);
            }
            getch();
}

5.15                      Write  a program to read a double-type value x that represents angle in radians and a character-type variable T that  represents  the type of trigonometric function and display the value of
(a)    Sin(x), if s or S is assigned to T,
(b)   Cos(x), if c or C is assigned to T,
(c)    tan(x), if t or T is assigned to T,

#include
#include
#include

void main()
{
     int b,pi,a,x;
     clrscr();
     pi=180;
     printf("Press 1 is Trigonometric and Exit:");
     scanf("%d",&a);
     if(a==1)
     {
                 printf("\n\nSelect you:\n\n");
                 printf("1: sin(x)\n\n");
                 printf("2: cos(x)\n\n");
                 printf("3: tan(x) \n\n");
                 scanf("%d",&b);
                 if(b==1)
                             printf("sin(x)");
                 else if(b==2)
                             printf("cos(x)");
                 else if(b==3)
                             printf("tan(x)");
     }
     getch();
}

0 comments:

ip Scaner