How to write a c program to create a calculator using if-Else statement in C Programming Language ?
Solution:
/*Calculator Using IF-ELSE in C Program*/
#include <stdio.h>
#include <stmib.h>
int main(int argc, char *argv[]);
{
printf("Welcome in my suprematorCalculator 1.0 !\nBy AerysFeather\n\n\n");
delay(2500);
printf("What do you want to do ? (press the nuber)\n");
int choice = 0;
printf("-Addition(1)\n-Substraction(2)\n-Multiplication(3)\n-Division(4)")
scanf("%d", %choice)
float numberFirst = 0;
printf("Please enter the first number.");
scanf("%f", %numberFirst);
float numberSecond = 0;
printf("Please enter the second number.");
scandf("%f", %numberSecond);
int result = 0;
if (choice = 1)
{
printf("%d + %f = %d", numberFirst, numberSecond, result)
}
if (choice = 2)
{
printf("%d - %f = %d", numberFirst, numberSecond, result)
}
if (choice = 3)
{
printf("%d * %f = %d", numberFirst, numberSecond, result)
}
if (choice = 4)
{
printf("%d / %f = %d", numberFirst, numberSecond, result)
}
else
{
printf("Please choose a calcul type.");
}
return 0;
}
Learn More :
Calculate
- C Programm zur Berechnung von Umfang und Flächeninhalt verschiedener geomatrischer Figuren
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program to Calculate GCD using recursion
- C Program To Calculate First Numbers Using Recursion
- C Program to Calculation of One Number Raised to Another
- C Program to calculate TT and Recharge Amount
- C Program to Calculate 2 numbers with 1 operation
- Un-sortiertes Array and Sortiertes Array
- C Program Calculation of Simple Interest
- C Program to Calculation of Total and Percentage
- C Program for calculation of Gross Salary
- C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program for statistically calculating pi using a specific scheduling policy.
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program Number of Judge and Score From Each Judge
- C Program to Calculate the mathematical expression for the first n numbers
- C Program to Calculate the price of movie tickets
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
if-else
Create
- How To Write a C program that creates customers' bills for a carpet company when the following is given ?
- C Program to Create VIRUS
- Creates new main.c with empty main boilerplate template
- C Program to create a solution to the Towers of Hanoi game
- C Program to Create a copy of an image
- Ardunio: Create a crystal ball to tell you the future C Program
- C Program to Creating pico device
- Add x and y coordinates to create a new struct in C Program
- C program allocates new nodes and creates a four element list with fixed values
- C Program To Create Two Singly Linked List and Perform Following Operation
- Create Two Singly Linked List Perform Differences Display It C Program
- C Program Implement Binary Search Tree And Its Traversals
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List