Dropdowns

import java.util.Scanner; public class PrintCapitalString { public static void main(String[] args) { String st,wd=””,shortSt=””; int l; Scanner sc=new Scanner(System.in); System.out.print(“Enter String: “); st=sc.nextLine(); st=st+” “; l=st.length(); for (int i = 0; i < l; i++) { if(st.charAt(i)==’ ‘) { if(Character.isUpperCase(wd.charAt(0))) { System.out.println(wd); } wd=””; } else { char ch; ch=st.charAt(i); wd=wd+ch; } } } } […]

learn java study java

Example: 327 Multiply with 2: 327×2=654 Multiply with 3: 327×3=981 Now, concatenate the all number. “327”+”654″+ “981”= 327654981 Here we can see that all digits from 1 to 9 are available in concatenating string. import java.util.Scanner; public class FascinatingNumber { public static void main(String args[]) { int num, num2, num3; Scanner sc = new Scanner(System.in); […]

learn java study java

import java.util.Scanner; public class EvilNumber { public static void main(String[] args) { int n,num; Scanner sc = new Scanner(System.in); System.out.print(“Enter number=”); n = sc.nextInt(); int binaryDigits=0; String binary = “”; num=n; while (num > 0) { binary= num % 2 + binary ; if(num%2==1) { binaryDigits++; } num = num / 2; } if(binaryDigits%2==0) { […]

learn java study java

import java.util.*; public class InsertionSort { public static void main(String[] args) { int arr[] = new int[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print(“Enter the number ar[” + i + “]:”); arr[i] = sc.nextInt(); } int n = arr.length; int temp, j; for (int i = […]

learn java study java

import java.util.Scanner; public class DeletingElementFromArray { public static void main(String[] args) { int arr[] = new int[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print(“Enter the number ar[” + i + “]:”); arr[i] = sc.nextInt(); } int n = arr.length; int newarr[] = new int[n – 1]; […]

learn java study java

import java.util.Scanner; public class AddingElementInArray { public static void main(String[] args) { int arr[] = new int[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print(“Enter the number ar[” + i + “]:”); arr[i] = sc.nextInt(); } int n = arr.length; int newarr[] = new int[n + 1]; […]

learn java study java

A number is called Capricorn or Kaprekar number whose square is divided into two parts in any conditions and parts are added, the additions of parts is equal to the number, is called Capricorn or Kaprekar number. import java.util.Scanner; public class CapricornNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(“Enter […]

java java programs number based program

/*Program to find the LCM and HCF of two numbers*/ #include<stdio.h> int main(void) { int x,y,a,b; printf(“Enter two numbers : “); scanf(“%d%d”,&x,&y); a=x; b=y; while(a!=b) { if(ab) a=a-b; else b=b-a; } printf(“HCF of %d and %d is %d\n”,x,y,a); return 0; } Output: Enter two numbers : 36 48 LCM of 36 and 48 is 144 […]

c language tutorial learn c language study c language

/*P5.41 Program to find day of week from a given date*/ #include<stdio.h> int main(void) { int d,m,y,j,f,h,fh,day; printf(“Enter date(dd/mm/yyyy): “); scanf(“%d/%d/%d”,&d,&m,&y); j=d; switch(m-1) { case 11: j+=30; /*Fall thru in all cases*/ case 10: j+=31; case 9: j+=30; case 8: j+=31; case 7: j+=31; case 6: j+=30; case 5: j+=31; case 4: j+=30; case 3: […]

c language tutorial learn c language study c language

/*Program to get difference of two dates in years, months, days*/ #include<stdio.h> int main(void) { int d1,d2,d,m1,m2,m,y1,y2,y; printf(“Enter first date(dd/mm/yyyy): “); scanf(“%d/%d/%d”,&d1,&m1,&y1); printf(“Enter second date(dd/mm/yyyy): “); scanf(“%d/%d/%d”,&d2,&m2,&y2); if(d2<d1) { if(m2==3) { if(y2%100!=0 && y2%4==0 || y2%400==0) /*check for leap year*/ d2=d2+29; else d2=d2+28; } else if(m2==5 || m2==7 || m2==10 || m2==12) d2=d2+30; else d2=d2+31; […]

c language tutorial learn c language study c language
On this page