1.WAP a program to find the sum of any two decimal number using C programming.
#include <studio.h>
#include <conio.h)
main ()
{
float a, b, sum;
printf ("Enter the first decimal number;);
printf ("Enter the second decimal number")
scanf (''%f" &a);
printf (''enter the second decimal number'')
scanf ("%f" &a);
sum = a + b
printf ("sum of two number is %f", sum);
getch();
}
2.Write a program in C to find simple interest.
#include <studio.h>
int main( )
{
float principle, time, rate, SI;
printf ("Enter principle")
scanf (''%f", & principle);
printf ("enter a time;");
scanf ("%f", & rate);
SI=( principle * time * rate)/100
printf ("simple interest = %f"; SI);
return 0
3.wap to find out the greatest number among 3 entered numbers.
#include <studio.h>
int main < >
{
double n1, n2, h3;
printf ("Enter three different numbers ;");
scanf ("% If %If %if''; & n1, &n2, &n3);
// if n1 is greater than n2 and n3, n1 is the largest
if (n1) = n2 && n1>=n3)
printf ("%, 2f is the greater number''; n1
// if n2 is the greater than both n1 and n3, n2 is the largest
elseif (n2>= n1 && n 2 >=n3)
printf (''%, 2 is the greater number"; n2);
// if the both above conditions are false, n3 is the grater
else
printf ("% 2 is the largest number";n3);
return 0
4. wap to find out if a number is even or odd using the if-else statement in C programming.
#include <studio.h>
int main ()
int num 1
printf (" enter a number");
scanf ("%d", & num1)
if (num1%2 == 0) // test-condition
{
printf ("num1 is even number");
}
else
printf(" num 1 is odd number");
return 0;
5.WAP to enter the sides of a triangle and find out if its equilateral or not.
#include <studio.h>
int main()
{
int a, b, c
printf ("Enter three sides of triangle");
scanf ("%d %d %d", & a, b, c);
if (a= = b && b== c)
printf ("Equilateral triangle");
}
else
{
printf ("scalene triangle");
}
return 0;
}
No comments:
Post a Comment