#include <stdio.h>
int main (void)
{
char x,a,s,m,d;
double y,z;
printf("Please Select The Character\nfor addition press
a\nfor subtraction press s\nfor Division press d\nfor
Multiplication press m\n");
scanf("%c",&x);
if(x=='a')
{
printf("Enter the first number: ");
scanf("%lf",&y);
printf("Enter the second number: ");
scanf("%lf",&z);
printf("The Addition is: %lf\n",y+z);
}
else if (x=='s')
{
printf("Enter the first number: ");
scanf("%lf",&y);
printf("Enter the second number: ");
scanf("%lf",&z);
printf("The Subtraction is: %lf\n",y-z);
}
else if (x=='d')
{
printf("Enter the first number: ");
scanf("%lf",&y);
printf("Enter the second number: ");
scanf("%lf",&z);
printf("The Division is: %lf\n",y/z);
}
else if (x=='m')
{
printf("Enter the first number: ");
scanf("%lf",&y);
printf("Enter the second number: ");
scanf("%lf",&z);
printf("The Multiplication is: %lf\n",y*z);
}
else
{
printf("You entered the wrong Character :(\n");
}
system("pause");
return 0;
}
Showing posts with label C-Test Program. Show all posts
Showing posts with label C-Test Program. Show all posts
How to make a simple calculator using C program
Find the Area of a Triangle
#include <stdio.h>
int main (void)
{
double base, height, area;
float z;
printf("Enter the Triangle's Base: ");
scanf("%lf",&base);
printf("Enter the Height: ");
scanf("%lf",&height);
area = 0.5*base*height;
printf("The area of the Triangle is: %lf\n", area);
system("pause");
return 0;
}
Find the Area of a Parallelogram
#include <stdio.h>
int main (void)
{
double area,length, breadth;
printf("Enter the length: ");
scanf("%lf",&length);
printf("Enter the breadth: ");
scanf("%lf",&breadth);
area=length*breadth;
printf("The Area of the Parallelogram is %lf\n",area);
system("pause");
return 0;
}
Find The Average Number
#include "stdio.h"
int main (void)
{
int main (void)
{
char name[100];
float score1, score2, score3, avg;
printf("Please enter your name: ");
scanf("%s",&name);
printf("Please enter the first score: ");
Line Space
#include "stdio.h"
int main (void)
{
char line [1000];
scanf("%[ ABCDEFGHIJKLMOPQRSTUVWXYZ]",&line);
printf("%s\n",line);
system("pause");
return 0;
}
int main (void)
{
char line [1000];
scanf("%[ ABCDEFGHIJKLMOPQRSTUVWXYZ]",&line);
printf("%s\n",line);
system("pause");
return 0;
}
Find The Prime Number
#include "stdio.h"
int main (void)
{
int number;
printf("Enter a number within (10-100):\n");
int main (void)
{
int number;
printf("Enter a number within (10-100):\n");
Find A Number Which is a Multiple of 2 & 5
#include "stdio.h"
int main(void)
{
int a;
printf("Input an integer and push return:\n");
scanf("%d", &a);
int main(void)
{
int a;
printf("Input an integer and push return:\n");
scanf("%d", &a);