MY mENU


Wednesday, 21 March 2012

Addition of Two Numbers in C++

Addition of Two Numbers in C++:

#include
#include
void main ()
   {
        int a,b,c;
         clrscr ();
           cout <<" Enter A: ";
              cin >>a;
                cout <<" Enter B: ";
                   cin >>b;
                      c= a+b;
                        cout <<"\n Addition is: "<               getch ();
        }

Fibonacci Series c language

Fibonacci Series c language 

 #include
    main() {
        int n, first = 0, second = 1, next; 
           printf("Enter the number of terms\n");
              scanf("%d",&n);
                printf("First %d terms of Fibonacci series are :-\n",n); 
                   for ( int i = 0 ; i< n ; i++ ) { 
                      if ( i<= 1 ) 
                       next = i; 
                         else { 
                           next = first + second; 
                             first = second; 
                               second = next; 
                                 } 
                         printf("%d\n",next); 
                  } 
          return 0; 
    }

Random Numbers in Java

Write a program to generate 5 Random nos. between 1 to 100, and it. should not follow with decimal point.

class RandomDemo{
      public static void main(String args[]){
          for(int i=1;i<=5;i++){
              System.out.println((int)(Math.random()*100));
          }
    }
}