saving . . . saved Assignments has been deleted. Assignments has been hidden .
Assignments
Title
Question
How to solve the expression (a/b)+(c/d) using typecasting in c

C-and-Cpp Increment-And-Decrement-Operators 11-12 min 20-30 sec 16-10-20, 11:25 p.m. Ammu15

Answers:

abc
17-10-20, 12:02 p.m. VarshaChaprana


Means what 
17-10-20, 10:31 p.m. Ammu15


That's only assignment.
20-06-21, 10:18 p.m. Sujan_A_T


#include <stdio.h>

int main() {
   int a, b, c, d;
   printf("Enter a and b: ");
   scanf("%d %d", &a, &b);
   printf("Enter c and d: ");
   scanf("%d %d", &c, &d);
   float ans = (a/b)+(c/d);
   printf("Answer(without typecast) = %f\n", ans);
   
   ans = ((float)a/b)+((float)c/d);
   printf("Answer(with typecast) = %f\n", ans);
   return 0;
}

Tell if there is wrong.
20-06-21, 10:19 p.m. Sujan_A_T


<font size="4">Program in c to solve the expression (a/b)+(c/d):</font>

#include <stdio.h>

int main()
{
   int a,b,c,d;
   float x,y,z;
   printf("Enter the values of a,b,c and d:");
   scanf("%d%d%d%d",&a,&b,&c,&d);
   x=a/b;
   y=c/d;
   z=x+y;
   printf("Value of x is %.2f\n",z);
   x=(float)a/b;
   y=(float)c/d;
   z=(float)x+y;
   printf("Value of x is %.2f\n",z);
   return 0;
}

output:

Enter the values of a,b,c and d:3
2
1
4
Value of x is 1.00
Value of x is 1.75

22-01-24, 4:20 p.m. Vaishnavi2885


Log-in to answer to this question.