0% found this document useful (0 votes)
4 views4 pages

The Sum and The Difference Code C Language

The document contains a C program that performs basic arithmetic operations: addition, subtraction, multiplication, and division based on user input. Users are prompted to enter a number corresponding to the desired operation, followed by two numbers for the calculation. The program uses 'goto' statements to navigate to the appropriate operation section and displays the result.

Uploaded by

harshyudi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

The Sum and The Difference Code C Language

The document contains a C program that performs basic arithmetic operations: addition, subtraction, multiplication, and division based on user input. Users are prompted to enter a number corresponding to the desired operation, followed by two numbers for the calculation. The program uses 'goto' statements to navigate to the appropriate operation section and displays the result.

Uploaded by

harshyudi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

The sum and the difference code

#include <stdio.h>
int d;
float j,u,w,a,b,c,e,f,g,h,s,k,l;
int main()
{
// Write C code here
printf("The enter number 8 for addion and 7 for subtraction and 9 for multiplication and 11
for division");
printf("\nenter the number = ");
scanf("%d",&d);
if(d==8)
{
goto mm;
}
if(d==7)
{
goto nn;
}
if(d==9)
{
goto rr;
}
if(d==11)
{
goto ee;
}
mm:
printf("the sum of two number");
printf("\nenter the first number = ");
scanf("%f",&a);
printf("\n\nenter the second number=");
scanf("%f",&b);
c=a+b;
printf("\n\nthe sum is =%f",c);
return 0;
nn:
printf("the difference between the two number" );
printf("\nenter the first number = ");
scanf("%f",&h);
printf("\n\nenter the second number=");
scanf("%f",&g);
f=h-g;
printf("\n\nthe difference is = %f",f);
return 0;
rr:
printf("the product of two number");
printf("\nenter the first number = ");
scanf("%f",&s);
printf("\n\nenter the second number=");
scanf("%f",&l);
k=s*l;
printf("\n\nthe product is = %f",k);
return 0;
ee:
printf("the quotient of two number");
printf("\nenter the first number = ");
scanf("%f",&u);
printf("\n\nenter the second number=");
scanf("%f",&w);
j=u/w;
printf("\n\nthe product is = %f",j);
return 0;
}

https://www.programiz.com/online-compiler/2Hdn4fhFEL3s4
https://www.programiz.com/online-compiler/5oVfRXqhqE7MO
https://www.programiz.com/online-compiler/5YuDvTWQJtXF9

// Online C compiler to run C program online


#include <stdio.h>
int d;
double j,u,w,a,b,c,e,f,g,h,s,k,l;
int main()
{
// Write C code here
printf("The enter number 8 for addion and 7 for subtraction and 9 for multiplication and 11
for division");
printf("\nenter the number = ");
scanf("%d",&d);
if(d==8)
{
goto mm;
}
if(d==7)
{
goto nn;
}
if(d==9)
{
goto rr;
}
if(d==11)
{
goto ee;
}
mm:
printf("the sum of two number");
printf("\nenter the first number = ");
scanf("%lf",&a);
printf("\n\nenter the second number=");
scanf("%lf",&b);
c=a+b;
printf("\n\nthe sum is =%lf",c);
return 0;
nn:
printf("the difference between the two number" );
printf("\nenter the first number = ");
scanf("%lf",&h);
printf("\n\nenter the second number=");
scanf("%lf",&g);
f=h-g;
printf("\n\nthe difference is = %lf",f);
return 0;
rr:
printf("the product of two number");
printf("\nenter the first number = ");
scanf("%lf",&s);
printf("\n\nenter the second number=");
scanf("%lf",&l);
k=s*l;
printf("\n\nthe product is = %lf",k);
return 0;
ee:
printf("the quotient of two number");
printf("\nenter the first number = ");
scanf("%lf",&u);
printf("\n\nenter the second number=");
scanf("%lf",&w);
j=u/w;
printf("\n\nthe product is = %lf",j);
return 0;
}

https://www.programiz.com/online-compiler/4eYOWvRDE8G1w

You might also like