randomposts
Powered by Blogger.
Showing posts with label Java. Show all posts

Write a program to print n step of the following series, 1, 3, 6, 11, 18, 29… Code in Java Programming

No comments


Write a program to print n step of the following series, 1, 3, 6, 11, 18, 29… Code in Java Programming Here...

import java.util.*; ___(Don't Missing Syntax required)
class series
{
     public static void main(String args[])___(Don't Missing Syntax required)
     {
           int r,a,c,n,s;
           Scanner sc=new Scanner(System.in);___(Don't Missing Syntax required)
          
           System.out.print("First Enter The Ranging Number:");___(Don't Missing Syntax required)
           r=sc.nextInt();___(Don't Missing Syntax required)
           n=1;
           s=1;
           while(s<=i)
           {
                c=0;
                a=1;
                while(a<=n)
                {
                     if(n % a == 0)
                     {
                           c=c+1;
                     }
                     a=a+1;
                }
          
                if(c==2)
                {
                     System.out.print(s + ",");___(Don't Missing Syntax required)
                     s=s+n;
                }
                n=n+1;
           }
     }    
}

Note: *Remove The Sentence on this program ___(Don't Missing Syntax required).

Write a program to print n steps of a Fibonacci series using for loop Code in Java Programming

No comments

Write a program to print n steps of a Fibonacci series using for loop Code in Java Programming:
import java.util.*; 
class fibonacci
{
     public static void main(String args[])
     {
           int  t,a,b,n;
          /* Syntax */ Scanner scanner name=new  Scanner(System.in);
          /* Syntax */ System.out.print("Enterd Numberd ");
           n=sc.nextInt();
           a=1;
           b=1;
           for(t=0;t<=n;t=a+b)
           {
                System.out.print(t + ",");
                a=b;
                b=t;
           }
     }
}

Write a program that uses all the escape sequences to print the characters code in Java Programming

No comments


import java.util.*;
import java.io.*;

class q2
{
     public static void main(String args[ ])
     {
           System.out.println("escape character  sequences ");
           System.out.println("\\n-new line escape character  sequences");
           System.out.println("\\t-horizontal tab escape character  sequences");
           System.out.println("\\b-back space escape character  sequences");
           System.out.println("\\v-vertical tab escape character  sequences");
           System.out.println("\\f-form feed escape character  sequences");
           System.out.println("\\a-alert noise escape character  sequences");
           System.out.println("\\o-optical escape character  sequences");
           System.out.println("\\r- escape character  sequences");
           System.out.println("\\q-question mark escape character  sequences");
     }
}

Note: *Remove The Sentence on this program ___(Don't Missing Syntax required).