Advertisements

Search results for float

Example:[1]

            Write a c program function to calculate the circumference of a circle if the radius of the circle is passed to it.

          

            #include <stdio.h>
#define PI 3.14
float Circum(int );
int main()
{
	int rad = 32;
	float r;
	r = Circum(rad);
	printf("The area of the circle is %f\n",r);
	return 0;
}
float Circum(int r)
{
	return (2 * PI * r);
}

          
Example:[2]

            Write a c program function to calculate the area of a circle if the radius of the circle is passed to it.
          

            #include <stdio.h>
#define PI 3.14
float Area(int );
int main()
{
	int rad = 32;
	float r;
	r = Area(rad);
	printf("The area of the circle is %f\n",r);
	return 0;
}
float Area(int r)
{
	return (PI * r * r);
}
          
Example:[3]

            Write a c program function to accept the temperature in Deg Centigrade and convert it to Fahrenheit.
          

            #include <stdio.h>
float celtofarenheit(int );
int main()
{
	int c = 32;
	float r;
	r = celtofarenheit(c);
	printf("The result is %f\n",r);
	return 0;
}
float celtofarenheit(int cel)
{
	return ((cel * 1.8) + 32);
}

          
Example:[4]

            Write a c program function to accept the principal, rate of interest, period of deposit and to calculate the simple interest.
          

            #include <stdio.h>
float sinterest(int ,float ,int );
int main()
{
   int princ = 10000;
   float rate = 3.875;
   float ra = rate/100;
   int period = 5;
   float r;
   r = sinterest(princ,ra,period);
   printf("The Simple interest is %f\n",r);
   return 0;
}
float sinterest(int p,float r,int t)
{
   return (p*(1 + r * t));
}
          
Example:[5]

            Write a c program function to create simple calculator using switch case.
          

            #include <stdio.h>
int main()
{
    char op;
    float num1, num2, result=0.0f;
    printf("Enter [number 1] [operator] [number 2]\n");
    scanf("%f %c %f", &num1, &op, &num2);
    switch(op)
    {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - num2;
            break;
        case '*':
            result = num1 * num2;
            break;
        case '/':
            result = num1 / num2;
            break;
        default:
            printf("Unsupported Operator");
    }
    printf("%.2f %c %.2f = %.2f\n", num1, op, num2, result);
    return 0;
}
          

 Search Links


 Popular C search MCQs


 Popular C search examples