Monday, 13 February 2017

11C-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

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

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

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

Wednesday, 1 February 2017

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




  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