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


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d;
float x,y,z;
printf("enter the a,b,c,d value");
scanf("%d%d%d%d",&a&b&c&d);
x=a/b;
y=c/d;
z=x+y;
printf("value of z is %2f",z);
getch();
}


12-08-24, 3:01 p.m. 238T1A05D8


#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
12-08-24, 3:01 p.m. 238T1A05D3


#include<stdio.h>
void main()
{
   int a,b,c,d,x,y;
   float ans;
   printf("Enter a and b values:");
   scanf("%d %d",&a,&b);
   printf("Enter c and d value:");
   scanf(%d %d",&c,&d);
   x=(float)a/b;
   y=(float)c/d;
   ans=x+y;
   printf("The final answer is %d",ans);
   getch();
}
   
12-08-24, 4:12 p.m. ajayrahulpulli@gmail.com


#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;
}


16-08-24, 4:53 p.m. 238T1A05F5


/* program to solve the following expression: (a/b) + (c/d) The values of a, b, c and d are taken as input from the user.using typecasting to perform real division*/
#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;
}



19-08-24, 2:49 p.m. 238T1A05G1


#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;
}
19-08-24, 3:04 p.m. nasreensk2005@gmail.com


Log-in to answer to this question.