Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Urgent Help In C...........


  • Please log in to reply
3 replies to this topic

#1 gunner55

gunner55

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:10:34 AM

Posted 09 September 2007 - 11:19 AM

the programming language is C

/.....its about a camera's exposure and apeture values...\

the question is write a test code that does the following when run..

The test code must do the following in this order:

1) Prompt for and then accept an exposure time.
2) Prompt for and then accept an aperture.
3) If the aperture is not one of the acceptable aperture values
then an error is reported and the program exits.
4) The exposure time and aperture is then printed out with a suitable heading.

NOTE:
the apeture values are : f1.2, f2.2, f4, f12, f18 and f32 (these values include the 'f',not only the number)

please reply as soon as possible.....its due tomoro at 17.30...

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:09:34 AM

Posted 09 September 2007 - 01:44 PM

Well, we are not about to do your homework for you. Perhaps you should have started sooner? At any rate, show us what you have, and we will be happy to help you with any problems you may be having, but we are not going to do your homework for you... not unless you want to do my combinatorics homework for me :thumbsup:

#3 gunner55

gunner55
  • Topic Starter

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:10:34 AM

Posted 09 September 2007 - 10:04 PM

its not that i want the homework to be done..jus for you to help...but neway ill post what i came up with...the code compiles and runs....but my code only accepts the apeture values without the 'f'...i realised too late that we need the f....so what do i need to change in the code to make it work if for example when 'f1.8' is entered it should accept....

#include<stdio.h>
int main(int argc, char * argv[])
{
FILE * output = stdout;
FILE * input = stdin;

float apeture;
int exposure;
int i = 0;
float apvalues[] = {1.2, 1.4, 1.8, 2.0, 2.8, 4, 5.6, 8, 11, 16, 22, 32}; //this is where im not sure...does is have to be a
//char array....it doesnt work right though...


{
fprintf(output,"\nplease enter exposure number:");
fprintf(output,"------->");
fscanf(input,"%d",&exposure);
}


int found = 0;

{
fprintf(output,"please enter apeture size:");
fprintf(output,"------->");
fscanf(input,"%f",&apeture);
}

for ( i=0;i<12;i++)
{
if (apeture == apvalues[i])
{
fprintf(output,"valid apeture value");
found = 0;
break;
}
else{
found = 1;
}

}

if (found == 1)
{
fprintf(output,"invalid apeture value");
return(0);
}


printf("\nThe camera has an apeture value of %.2f and exposure time of %d\n",apeture, exposure);

}



thats what i got...

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:09:34 AM

Posted 10 September 2007 - 09:02 AM

If you want to use a char array, the values need to be enclosed in double quotes..

apvalues[] = {"f1.2", "f1.4", "f1.8"...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users