This program shows the multiplication of any user defined number.
C Program to display sum of square up to 10
This is a simple java code that shows the sum of square of all digit from 1 to 10. You can run this program and check the output on any C platform.
Example:
C Program to display Grade
This Program to display Grade C less than 30, Grade B less than
40 and Grade A less than 50
C Program to calculate two number is even or odd
This program calculates whether the given two inputs sum is odd or even
C Program to calculate perimeter and area of triangle with 3 sides
This programs find the perimeter and area of triangle by asking 3 sides length values
C Program to Calculate perimeter and area of circle
This program calculates the perimeter and area of circle
#include <stdio.h>
#include <math.h>
main ()
{
float r, p, a;
printf ("Enter the radius of Circle:");
scanf ("%f", &r);
p = 2 * 3.14 * r;
a = 3.14 * r * r;
printf ("The perimeter of circle is:%f\n", p);
printf ("The area of circle is:%f\n", a);
getch();
}
Output:--
Enter the radius of Circle: 2.5
The perimeter of circle is: 15.7
The area of circle is: 19.6
How it works
It asks for the radius of circle and calculates the perimeter and area of a circle by using circle formula
C Program to convert centigrade into Fahrenheit and Kelvin
This program ask input in degree celsius and gives output in fahrenheit and Kelvin
#include <stdio.h>
#include <math.h>
main () {
float c, fe, k;
printf ("Enter the temperature in Degree Celsius:");
scanf ("%f", &c);
fe = 1.8 * c + 32;
k = 273 + c;
printf ("The temperature in Fahrenheit is:%f\n", fe);
printf ("The temperature in Kelvin is:%f\n", k);
getch ();
}
Output::---
Enter the temperature in Degree Celsius: 20.0
The temperature in Fahrenheit is: 68.0
The temperature in Kelvin is: 293.0
How it works
After getting value in degree celsius, it calculate Fahrenheit and Kelvin by using conversion formula shown in the above program.
C Program to Calculate Simple Interest
Program to calculate total interest value with principal amount, rate and time in year.
#include <stdio.h>
#include <math.h>
main ()
{
float p, t, r, si;
printf ("Enter Principal:");
scanf ("%f", &p);
printf ("Enter Rate:");
scanf ("%f", &r);
printf ("Enter Time:");
scanf ("%f", &t);
si = p * t * r / 100;
printf ("The Simple Intrest is:%f\n", si);
getch ();
}
Output:--
Enter Principal: 15000.0
Enter Rate: 25.0
Enter Time: 2.5
The Simple Interest is: 9375.0
How it works
It asks for principal amount, rate of interest and total time in year. Then it calculates the interest by using simple interest formula and gives total interest to be paid at the end.
C Program to find odd or even
This program shows given number is odd or even.
#include <stdio.h>
#include <math.h>
main () {
int a, b;
printf ("Enter the Number:");
scanf ("%d", &a);
b = a % 2;
if (b == 0)
{
printf ("The given Number %d is even\n", a);
}
else
{
printf ("The given Number %d is odd\n", a);
}
getch();
}
Output::--
Enter the Number: 20
The given Number 20 is even
How it works
After getting input, it divides the number by 2 and check if its remainder is 0 or not. If 0 then it shows as even else odd
C Program to sum 2 numbers...
Get sum of two number
#include <stdio.h>
#include <math.h>
main ()
{
int a, b, c;
printf ("Enter the value of a & b:");
scanf ("%d%d", &a, &b);
c = a + b;
printf ("sum of the two numbers is:%d\n", c);
getch ();
}
Output:-
Enter the value of a & b: 2 , 3
Sum of the two numbers is: 5
How it works
After getting two numbers, it does sum and prints the total.
Subscribe to:
Comments (Atom)