any C programmers out there?

  • Thread starter Thread starter Kigs!
  • Start date Start date
  • Tagged users Tagged users None

Kigs!

zoa santa
View Badges
Joined
Feb 16, 2007
Messages
1,954
Reaction score
1
Rating - 0%
0   0   0
Taking a class on it, regretting it now as I am miserably lost. Please help, any help would be mucho apprecieated.

"Given that two int variables, total and amount , have been declared, write a sequence of statements that:
initializes total to 0
reads three values into amount , one at a time.
After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). "
 
C is still used? i took an AP class way back in highschool on Pascal....then it was replaced the next year with C++

...i was completely lost with C++...it felt completely different
 
Hehe yea, the professor is notorious for ambiguous directions. I apprecieate the help Jeremy. I think your answer is WAY more advanced than what I was expecting lol. This is what my TA sent me.

"total = 0
scanf("%d",&amount);
total = total + amount

total = 0
scanf("%d",&amount);
total = total + amount

total = 0
scanf("%d",&amount);
total = total + amount"

How about these?
Write a switch statement that tests the value of the char variable response and performs the following actions:
if response is y , the message Your request is being processed is printed
if response is n , the message Thank you anyway for your consideration is printed
if response is h , the message Sorry, no help is currently available is printed
for any other value of response , the message Invalid entry; please try again is printed

This is what I have so far,
switch(response)
{
case 1 :
printf("Your request is being processed\n");
break;

case 2 :
printf("Thank you anyway for your consideration\n");
break;

case 3 :
printf("Sorry, no help is currently available is printed\n");
break;

default : printf("Invalid entry; please try again\n");
}


Another one;

Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variables neutral , base , and acid :
0, 0, 1 if pH is less than 7
0, 1, 0 if pH is greater than 7
1, 0, 0 if pH is equal to 7

What I have so far;;
if(pH < 7; )
{neutral == 0 && base == 0 && acid == 1}
else if(pH > 7; )
{neutral == 0 && base == 1 && acid == 0}
else(pH = 7; )
{neutral == 1 && base == 0 && acid == 0}

vice versa with pH and neutral. :)
 
I'm at my senior year of my major and I'm slowly making a transition into my true passion; biomedical engineering. If it wasn't due to my laziness, that's what I would've pursued right out of highschool, but due to laziness I ended up at an architecture school lol.

Thanks for the luck man, I'll need it. I'm sooo lost... The class is soley based on C programming, and required course for the freshman in the major, which was a bit odd because from what I understand, C programming is somewhat outdated.
 
What, no Fortran 77/90:D? The only use I can see in it is a very basic understanding of programming (you learn quickly to curse compilers for vague, ambiguous errors messages).
 

TOP 10 Trending Threads

Back
Top
Home
Post thread…
Market
What's new