Category Archives: Uncategorized

C programming (More Arithmetic operations)

#include <stdio.h>
#include <conio.h>

int main(void)
{
    int num1,num2,sum,mult,div,sub,rem;
    printf ("Enter the first value : ");
    scanf ("%d",&num1);

    printf ("Enter the second value : ");
    scanf ("%d",&num2);

    sum=num1+num2;
    mult=num1*num2;
    div=num1/num2;
    sub=num1-num2;
    rem=num1%num2;

    printf ("The sum is : %d\n",sum); // Sum function
    printf ("The multiplication is : %d\n",mult);//Multiplication funtion
    printf ("The division is : %d\n",div);//Devision function
    printf ("The subsctraction is : %d\n",sub);//Substraction function
    printf ("The remainder is : %d\n",rem);//Remainder function

    getch();

    }

Sum square difference Program in java

The sum of the squares of the first ten natural numbers is,

12 + 22 + … + 102 = 385

The square of the sum of the first ten natural numbers is,

(1 + 2 + … + 10)2 = 552 = 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

Source Code:

public class SumSquareDifference {

public static void main(String s[]){

long k=0;

long j=0;

for(int i=1;i<=100;i++){

k=k+(i*i);

j=j+i;

}

System.out.println((j*j)-k);

}

}

Largest prime factor of the number in JAVA

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

Source Code:

import java.util.Scanner;

public class LargestPrimeNumber {

	public static void main(String s[]){
		
		System.out.println("Enter number for Prime Factor: ");
		Scanner obj =new Scanner(System.in);
		
		long j =obj.nextLong();
		long i;
		long k=0;
		
				for(i=2; i<j;i++){
					if(j%i==0){
						k=i;
						j=j/i;
					}
				}
				System.out.println("Largest Prime factor  is : "+ j);
	   }
}

C programming (More Maths Functions)

Hello,

In this post i will be sharing you awesome code that i just wrote, I tried to cover every basic maths function like Addition,Subtraction, Multiplication, division, remainders.

#include <stdio.h>
#include <conio.h>

int main(void)
{
    int num1,num2,sum,mult,div,sub,rem;
    printf ("Enter the first value : ");
    scanf ("%d",&num1);
    
    printf ("Enter the second value : ");
    scanf ("%d",&num2);
    
    sum=num1+num2; // Sum Function
    mult=num1*num2; // Multiplication Funtion
    div=num1/num2; //Division Function
    sub=num1-num2; //Subtraction Function
    rem=num1%num2; //Remainder Function
    
    printf ("The sum is : %d\n",sum); 
    printf ("The multiplication is : %d\n",mult);
    printf ("The division is : %d\n",div);
    printf ("The subsctraction is : %d\n",sub);
    printf ("The remainder is : %d\n",rem);
    
    getch();
    
    
    }

C programming (Simple addition of variables using Math function)

Hello,

So well in this post i will going to share my source code that i just wrote on how you can use Variables, and maths functions to so simple addition calculation.

#include <stdio.h>
#include <conio.h>

int main(void)
{
    int num1,num2,sum;// Defining variables
 
    printf ("Enter the first value : ");// To print on screen
    scanf ("%d",&num1); // scanf use for inputting and storing data in variable 
    
    printf ("Enter the second value : ");// To print on screen
    scanf ("%d",&num2);
    
    sum=num1+num2; // Math funtion for Addition 
  
    
    printf ("The sum is : %d\n",sum); // Funtion to Print Sum of two variables
    
    getch();
    
    
    }