03 December 2018

To convert from Upper case to lowercase(A to a)

//converting from Upper to lower(A to a)

import java.util.*;
class case
{
public static void main(String args[])
{
System.out.println(" Enter a text to convert in Upper case :");
String a,result;
Scanner obj=new Scanner(System.in);
a=obj.nextLine();
result=a.toLowerCase();
System.out.println(result);
}
}

Similar program :-

Java Program to convert from lower case to upper case(a to A)


To convert from lower case to upper case(a to A)

//converting from lower case to upper case(a to A)
import java.util.*;
class case
{
public static void main(String args[])
{
System.out.println(" Enter a text to convert in Upper case :");
String a;
Scanner obj=new Scanner(System.in);
a=obj.nextLine();
String result;
result=a.toUpperCase( );
System.out.println(result);
}
}

Similar program:-

Java Program to convert from Upper case to lowercase(A to a)

04 October 2018

Java--Calculate perfect number

 Perfect number : is a positive integers which is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself

(or)

Perfect number : is a positive integers which is equal to the sum of its proper positive factors, that is, the sum of its positive factors excluding the number itself

For example 
 6 has factors 1,2,3 and 6(number itself)
         import java.util.*;
class perfect{ public static void main(String args[]) { int n,sum=0; System.out.println("Enter a number: ");    Scanner obj=new Scanner(System.in); n=obj.nextInt();    for(int i=1;i<n;i++)        {        if(n%i==0)          sum+=i;        }    if(n==sum)        System.out.println(n+" is a Perfect number");    else        System.out.println(n+" is not Perfect number");     }
}

C --Calculate perfect number

Perfect number : is a positive integers which is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself

(or)

Perfect number : is a positive integers which is equal to the sum of its proper positive factors, that is, the sum of its positive factors excluding the number itself

For example 
 6 has factors 1,2,3 and 6(number itself)
#include<stdio.h>  int main()    {    int n,sum=0;    printf("Enter a number: ");    scanf("%d",&n);       for(int i=1;i<n;i++)        {        if(n%i==0)          sum+=i;        }    if(n==sum)        printf("\n %d is a Perfect number",n);    else        printf("\n %d is not Perfect number",n);return 0;
}


19 September 2018

C++ -Calculate perfect number


Perfect number : is a positive integers which is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself

(or)

Perfect number : is a positive integers which is equal to the sum of its proper positive factors, that is, the sum of its positive factors excluding the number itself

For example 
 
 6 has factors 1,2,3 and 6(number itself)

//C++ program to calculate perfect number
#include<iostream>
using namespace std;
  int main()
    {
    int n,sum=0;
    cout<<"Enter a number: ";
    cin>>n;   
    for(int i=1;i<n;i++)
        {
        if(n%i==0)
          sum+=i;
        }
    if(n==sum)
        cout<<n<<" is a Perfect number"<<endl;
    else
        cout<<n<<" is not Perfect number"<<endl;
return 0;
}
Similar program(s) :

C++ Program to find a given number is STRONG or not.
   

18 September 2018

C++ program to calculate x^n using recursion

//C++ program to calculate x^n using recursion
#include<iostream>
using namespace std;
int xn(int,int);
  int main()
    {
    int n,x,k;
    cout<<"Enter X value : ";
    cin>>x;
    cout<<"Enter N value : ";
    cin>>n;
    k=xn(x,n);
    cout<<"Power("<<x<<","<<n<<") = "<<k<<endl;
return 0;
}
    int xn(int x,int n)
   {
    int y=1;
    if(n>0 && n!=1)
       return (y*x)*xn(x,n-1);
    else if(n==0)
       return y;
    else
       return x*y;
   }
Output will be similar to this :



Similar program(s):
C++ program to calculate x power n(XN) 
   

C++ program to calculate x power n(x^n)

//C++ program to calculate x^n
#include<iostream>
using namespace std;
  int main()
    {
    int n,x,k;
    cout<<"Enter X value : ";
    cin>>x;
    cout<<"Enter N value : ";
    cin>>n;
    int y=1;
    for(int i=0;i<n;i++)
        {
        y=y*x;
        k=y;
        }
    cout<<"Power("<<x<<","<<n<<") = "<<k<<endl;
return 0;
}
Output will be similar to this :



Similar program(s):
C++ program to calculate x power n(X^N) using recursion
   

To convert from Upper case to lowercase(A to a)

//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...