C+........................Basi c c program
+ Reply to Thread
Results 1 to 3 of 3

Thread: C+........................Basi c c program

  1. #1
    Join Date
    Sep 2006
    Location
    Spiral Galaxy
    Posts
    12,308

    Default C+........................Basi c c program

    hi
    hru

    #include<stdio.h>
    #include<conio.h>
    #include<math.h>


    #define PI 3.14169
    #define VI 5
    #define L 4.3e-4
    #define C 5.1e-6
    #define R 5

    float calculate_Xl( float fc);
    float calculate_Xc( float fc);

    int main()
    {
    float fc,result,answer,v;
    clrscr();
    printf("Please enter the frequency==> ");
    scanf("%f",&fc);
    result=calculate_Xl(fc);
    answer=calculate_Xc(fc);
    v=(VI*R)/sqrt((result-answer)*(result-answer)+R*R);
    printf("The voltage out is %fvolts",v);
    getch();
    }
    float calculate_Xl( float fc)
    {
    float a;
    a=2*PI*fc*L;
    return a;
    }
    float calculate_Xc( float fc)
    {
    float a;
    a=1/(2*PI*fc*C);
    return a;
    }
    "Change the above program to input different values of R and out the frequency f where Vo is maximum. Use freequencies from 10 to 1 000,000" Hertz with an increment of 10 "'


    to get the R values i have to ask the user to input the value..........

    how do change the frequency??.i mean ho do i create loop for that??? ( i have to use for loop rite)

    help me pls

    thanks in advance

  2. #2
    Join Date
    Sep 2004
    Location
    Chennai
    Posts
    1,489

    Default

    remove the #define for R,
    instead of printf("Please enter the frequency==> ");
    scanf("%f",&fc);

    use

    printf("Please enter the R==> ");
    scanf("%f",&R);

    for(float fc=10;fc<1000000;fc+=10){ //check if range of float is enough...
    result=calculate_Xl(fc);
    answer=calculate_Xc(fc);
    v=(VI*R)/sqrt((result-answer)*(result-answer)+R*R);

    if(fc ==10) //first time, make vmax=v;
    vmax = v;
    else{
    if(v>vmax)
    vmax = v;
    }
    //now prit vmax
    }
    if thats what you want...
    I Will Be Back!!!

  3. #3
    Join Date
    Sep 2006
    Location
    Spiral Galaxy
    Posts
    12,308

    Default

    thanks friend
    நான் பெரிது நீ பெரிது என்று வாழாமல் நாடு பெரிது என்று வாழ்வோம்!

+ Reply to Thread

Similar Threads

  1. Learn `Basic Hindi`
    By sWEEtmICHe in forum General knowledge
    Replies: 66
    Last Post: 12-11-2009, 06:17 PM
  2. Carnatic Music - Basic Lessons
    By n_anush in forum Carnatic Learning Center
    Replies: 14
    Last Post: 12-17-2007, 02:40 AM
  3. basic element of love is nose
    By aerodon in forum Love & Relationship
    Replies: 15
    Last Post: 10-05-2006, 05:21 PM
  4. BASIC
    By science_physics in forum Programming Help
    Replies: 5
    Last Post: 10-05-2006, 01:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts