Saturday, 16 December 2017

11D-prg16 Write a algorithm and program to calculate commission of salesman. The commission is calculated according to the following rates (using function)



30001 onwards 15%
22001  to 30000 10%
12001 to 22000 7%
5000 to 12000 3%
0 to 5000 0%

Algorithm
Input
1. sa   //sales amount, float sa
Output
1. comm    //commission
2. Ta         //Total amount

Method:
1.start
2. read sa
3. write sa
4. salcom(sa);   // calling function
5. stop

1. // Function
    void salcom(float sa)
    begin
            if(sa >= 30001)
             begin
                 comm= sa*0.15;
                 Ta = sa + comm;
              end
              else
               if( sa>=22001 and sa<=30000 )
               begin
                 comm= sa*0.10;
                 Ta = sa + comm;
              end
             else
               if( sa>=12001 and sa<=22000 )
               begin
                 comm= sa*0.07;
                 Ta = sa + comm;
              end
             else
               if( sa>=5000 and sa<=12000 )
               begin
                 comm= sa*0.03;
                 Ta = sa + comm;
              end
               else
                begin
                     Ta=sa;
                 end
             print"Commission=",comm;
             print" Total Amount=",Ta;
    2.stop

Thursday, 14 December 2017

11-D 21. Write a algorithm and program using nested loops to produce the following designs: Using functions and with switch concept in the main program

21.   Write a program using nested loops to produce the following designs: Using functions

A)
*
**
***
****
*****
B)
1
12
123
1234
12345
C)
1
23
456
78910


 #include<iostream.h>
 #include<conio.h>

 void dis21A(int x)
 {

  int i,j;
  i=1;
  while(i<=x)
  {
  for(j=1;j<=i;j++)
  {
  cout<<"*";
  }
  cout<<"\n";
  i++;
  }
  }

 void dis21B(int x)
 {

  int i,j;
  i=1;
  while(i<=x)
  {
  for(j=1;j<=i;j++)
  {
  cout<<j;
  }
  cout<<"\n";
  i++;
  }
  }
 void dis21C(int x)
 {

  int i,j,k;
  i=1,k=1;
  while(i<=x)
  {
  for(j=1;j<=i;j++)
  {
  cout<<k<<"\t";
  k++;
  }
  cout<<"\n";
  i++;
  }
 }

  void main()
  {
  int x,ch ;
  clrscr();
  cout<<"enter x \n";
  cin>>x;
  cout<<"enter choice\n";
  cin>>ch;
  switch(ch)
  {
  case 1:{
  dis21A(x);
  break;
  }
  case 2:{
dis21B(x);
break;
}
   case 3:{
dis21C(x);
break;
}

  default:{
   cout<<"wrong choice\n";
   break;
  }
  }
  getch();
  }












Wednesday, 13 December 2017

11D-prg-17 Write a algorith and program whether a given character is an alphabet, digit or any other character.using function


Algorithm:

Input:
1. ch  //character

Output:
1. al/dig/spec

Method:
1. start
2. Read ch
3. Print ch
4. //logic

  if(isalpha(ch))
   Print " The character is an alphabet "
  else
  if(isdigit(ch))
   print " The character is an digit"
  else
   Print " It is a special character"
5.Stop

11D-Prg-20. Write a Algorithim and Program to find a given number is Angstrom or not. using function




  Write a Algorithim and Program to find a given number is Angstrom or not.
  Algorithim:
        Input:
    1.      Num 
Output 
1.      The Num is Armstrong or not
Method:
1.     Start
2.    .  Read Num
3.      Print Num
4.       //logic
T=Num;
Sum=0;
While(Num != 0)
{
    Rem = Num % 10;
    Cub = pow(Rem,3);
    Sum=Sum + Cub;
    Num = Num /10;
}
if (Sum = = T)
    Print “ The given no is Armstrong”;
else
    Print” The given no is not Armstrong”;
5.    .  Stop

11D-19 Write a program to print Fibonacci series i.e.0 1 1 2 3 5 8………using function



Algorithm:
Input:
1)n
Output:
1)fibonaci numbers 0 1 1 2 3 5 ...
Method:
1. Start
2. Read n
3. Print n
4. //logic
5. f1=0;
6. f2=1;
7. print f1 and f2
8. for(i=3;i<=n;i++)
   begin
     f3=f1+f2
     print f3
     f1=f2
     f2=f3
   end
9.stop

11D-18.-Prog Write a program to compute Cosine series i.e.


18.   Write a program to compute Cosine series i.e.
Cos(x)= 1 – x2/2! + x4/4! – x6/6! + …xn/n!
Algorithm:
Input
1. x   //x=2
2. n  //n=3
Output
1. cx    // cosine series
Method:
1. start
2. Read x
3. Read n
4. //logic
cx=1;
j=2;
for(i=2;i<=n;i++)
begin
     fact=1;
     for(k=j;k>=1;k--)
   begin
      fact=fact*k
   end
    if(i%2==0)
    {
      cx=cx-pow(x,j)/fact;
    }
    else
    {
       cx=cx+pow(x,j)/fact;
     }
   j=j+2;
end
loop end
5.print cx
6.stop