Showing posts with label SimplePrograms. Show all posts
Showing posts with label SimplePrograms. Show all posts

Write a word in both Upper Case and Lower Case

C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char Str[10];
    printf("Enter any Word: ");
    scanf("%s",&Str);
    printf("Word: %s\n",&Str);
    printf("UPPERCASE: %s \n", strupr(Str));
    printf("lowercase: %s ", strlwr(Str));
}



Python Program
S = input("Enter a sentence: ")
print("Lower case: " + S.lower())
print("Upper case: " + S.upper() )

C program to find Sin, Cos, Tan of a number

C Program
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   float x;
   printf("Enter Value of X:");
   scanf("%f",&x);
   printf("The sin of the value is :%f\n",sin(x));
   printf("The cos of the value is :%f\n",cos(x));
   printf("The tan of the value is :%f\n",tan(x));
}


Paper Measurement(Convert ream to sheets)

1 ream contains 500 sheets of paper

C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int s,r;
    printf("Enter total ream of paper:");
    scanf("%d",&r);
    s=r*500;
    printf("Total sheets of paper in %d ream is %d",r,s);
    return 0;
}


Java Program
import java.util.Scanner;

public class PaperMeasurement {

	public static void main(String[] args) 
	{
		Scanner S = new Scanner(System.in);
		int s,r;
		System.out.print("Enter total ream of paper:");
	    r= S.nextInt();
		s=r*500;
		System.out.print("Total sheets of paper in " +r + " ream is " + s);
	}

}

Caculate Profit

Profit is calculated by subtracting cost price from selling price.
That is, Profit = SellingPrice - CostPrice

C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int p,cp,sp;
    printf("Enter Cost Price:");
    scanf("%d",&cp);
    printf("Enter Selling Price:");
    scanf("%d",&sp);
     p=sp-cp;
    printf("Profit from the item is %d",p);
    return 0;
}


Java Program
import java.util.Scanner;

public class Profit {

	public static void main(String[] args) 
	{
		Scanner S = new Scanner(System.in);
		int p,cp,sp;
	    System.out.print("Enter cost Price:");
	    cp = S.nextInt();
	    System.out.print("Enter Selling Price:");
	    sp=S.nextInt();
	     p=sp-cp;
	    System.out.print("Profit from the item is " + p);
	  
	}

}

WorkDone(W=F*N)

C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int w,f,d;
    printf("Enter Force(N): ");
    scanf("%d",&f);
    printf("Enter Distance travelled  by the body(m): ");
     scanf("%d",&d);
    w=f*d;
    printf("The work done is %d Joules",w);
    return 0;
}


Java Program
import java.util.Scanner;

public class WordDone {

	public static void main(String[] args) 
	{
		Scanner S = new Scanner(System.in);
		 int w,f,d;
		    System.out.print("Enter Force(N):");
		    f= S.nextInt();
		    System.out.print("Enter Distance travelled  by the body(m): ");
		    d= S.nextInt();
		    w=f*d;
		    System.out.print("The work done is "+ w + "Joules");
	  
	}

}
Python Program
f = int(input("Enter total force applied: "))
d = int(input("Enter distance displaced: "))
w = f * d
print("Total work done is : " +  str(w))

OHMS LAW(V=IR)

Ohm’s law explains the relationship between voltage and current flowing through resistors. The mathematical formula is V=IR.

C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int v,i,r;
    printf("Enter current(Amphere):");
    scanf("%d",&i);
    printf("Enter Resistance(Ohm):");
    scanf("%d",&r);
     v=i*r;
    printf("Voltage of the circuit is %d",v);
    return 0;
}


Java Program
import java.util.Scanner;

public class Swap {

	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		int v,i,r;
		 System.out.print("current(Amphere):");
		i = s.nextInt();
	     System.out.print("Enter Resistance(Ohm):");
		r = s.nextInt();
		v=i*r;
		System.out.print("Voltage of the circuit is " + v);   
	}
}



Python Program
i = int(input("Enter value of current in amphere: "))
R = int(input("Enter value of Resistance in ohm: "))
v = i*R
print("The voltage(V) applied is: " + str(v))