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

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

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

Gets & Puts Function

#include "stdio.h"
int main (void)
{
    char line[80];

Find The Average Number

#include "stdio.h"
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 Example

#include "stdio.h"
int main(void)
{
    char line[1000];
    scanf("%[^\n]", line);

Line Break

#include "stdio.h"
int main(void)

{
    char line[1000];

Line Space

#include "stdio.h"
int main (void)
{
char line [1000];
scanf("%[  ABCDEFGHIJKLMOPQRSTUVWXYZ]",&line);
printf("%s\n",line);
system("pause");
return 0;
}

Line

#include "stdio.h"
int main (void)
{
    char line[1000];

Item, Part No. & Cost

#include "stdio.h"
int main (void)
{
char item [80];
int partno;

Find The Area of A Radius

#include "stdio.h"
#include "math.h"
double const pi=3.1416;

Do While_1.1

#include "stdio.h"
main( )
{

C Password

#include "stdio.h"
int main ()
{
    int pass;
    do
    {

Find The Area

#include "stdio.h"
#include "math.h"
int main(void)
{

Input 3 Integer and Find The Average of Them

#include "stdio.h"
int main (void)
{
    int a,b,c, average;

Find The Prime Number

#include "stdio.h"
int main (void)
{
 int number;
 printf("Enter a number within (10-100):\n");

Find Negative Or Positive Number

#include "stdio.h"
#include "conio.h"
int main (void)
{
    int a;

Uses of Strlen, Strupr, Strlwr, Strrev

#include "stdio.h"
int main (void)
{
    char name[100];

Find The Greatest Number

#include
int main (void)
{
    int x,y;

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);