Saturday, April 13, 2013

Check Prime Number or Not in C

Check Prime Number or Not 



#include<stdio.h>
#include<conio.h>
main()
{
 int pm,i,flag=1;
 printf("enter the number\n");
 scanf("%d",&pm);
 for(i=2;i<pm;i++)
 {
  if((pm % i)==0)
        
         {
          printf("Then given number is not prime\n");
          flag=0;
          break;
         }
 }
  if (flag==1)
     printf("The given number is prime\n");
}

Friday, April 12, 2013

Sum of Current supply I=I1+I2+I3+.....................+In

Sum of Current supply I=I1+I2+I3+.....................+In 

 

#include<stdio.h>
#include<conio.h>
main()
{
    int n,i,j,I=0,v,r,sum=0;
    printf("\t*Its's a programe to find the total current supply of a circuit bord*\n");
    printf("\n\nHow many curent supply point you use in serise bord: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=1;j++)
        {
            printf("\nEnter the value of %d voltage: ",i);
            scanf("%d",&v);
            printf("\nEnter the valo of %d registance: ",i);
            scanf("%d",&r);
            I=v/r;
        }
        //printf("\n\tEnter the valuse of %d registor:",i);
        //scanf("%d",&j);
        sum+=I;
    }
    printf("\n\tThe total current supply of circuit board is: %d\n ",sum);
}

Parallel Resistance (1/Ri=1/R1+1/R2+1/R3+.......+1/Rn)

Parallel Resistance


#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
    int i,j,n;
    float a=1.0,b,c=0.0,sum=0.0,temp=0.0;
    printf("\tIt's a programe of 1/Ri=1/R1+1/R2+1/R3+.......+1/Rn\n");
    printf("\n\nEnter the number of registors in parallel: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=1;j++)
        printf("\n\tEnter the valuse of %d registor:",i);
        scanf("%f",&b);
        c=a/b;
        sum+=c;
    }
    temp=a/sum;
    printf("\n\nThe total registance(1/Ri) of parallel is: %0.3f\n ",sum);
    printf("\nThe total registance(Ri) of parallel is: %0.3f\n\n ",temp);

}

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


}