Friday, April 12, 2013

Voltage,Registance,Current flow

V=IR
I=V/R
R=V/I

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
    float v,i,r,sum=0.0;
    char ch;
    printf("\t\t\tWell Come to V=IR programe:\n");
    printf("\nPlease press a for V, b for I and c  for R : ");
    scanf("%c",&ch);
    switch (ch)
    {
        case 'a':
        printf("\n\tEnter the value of current: ");
        scanf("%f",&i);
        printf("\n\tEnthe the value of rigistance: ");
        scanf("%f",&r);
        sum=i*r;
        printf("\nThe result is V= %0.3f\n",sum);
        break;
        case 'b':
        printf("\n\tEnthe the value of voltage: ");
        scanf("%f",&v);
        printf("\n\tEnthe the value of rigistance: ");
        scanf("%f",&r);
        sum=v/r;
        printf("\nThe result is I= %0.3f\n",sum);
        break;
        case 'c':
        printf("\n\tEnthe the value of voltage: ");
        scanf("%f",&v);
        printf("\n\tEnther the value of current: ");
        scanf("%f",&i);
        sum=v/i;
        printf("\nThe result is R= %0.3f\n",sum);
        break;
    }


}

1 comment:

  1. #include
    main()
    {
    char a;
    float I,V,R,sum=0.0;
    printf(" -:For V=IR press 'A',For I=V/R press 'B',For R=V/I press 'C':-\n");
    scanf("%c",&a);

    switch(a)
    {
    case'A':
    printf("Enter the value of corrunt:");
    scanf("%f",&I);
    printf("Enter the value of resestence:");
    scanf("%f",&R);
    sum=I*R;
    printf("%f",sum);
    break;
    case'B':
    printf("Enter the value of voltage:");
    scanf("%f",&V);
    printf("Enter the value of resestance:");
    scanf("%f",&R);
    sum=(V/R);
    printf("%f",sum);
    break;
    case'C':
    printf("Enter the value of voltage:");
    scanf("%f",&V);
    printf("Enter the value of current:");
    scanf("%f",&I);
    sum=(V/I);
    printf("%f",sum);
    break;
    }
    }

    ReplyDelete