Need help with an exercise.

So i got an exam now, and i am not ready for it, so im counting on you guys!

N people came to conference. Transporting them from hotel to conference a number of cars is given, their capacity(not including driver) is K or M people. Cars at hotel go this way, first car with capacity K(people),after that comes car with capacity M, then again K, and M and so on.. Each car can transport only so much people as given in exercise.We need to make programme, about how much cars are needed to transport all people.

P.S sorry for english translation, exercise is in latvian.

User inserts 3 natural numbers- N, K and M values. Its known, that 0<N<2147483648, 0<K<100, 0<M<100.

Im really counting on your help guys, thanks for your time.
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void main()
  int x,N,K,M;
  cout<<"Ievadi cik cilveki ieradas uz konferenci: "; cin>>N;
  cout<<"Ievadi cik cilveki var iekapt pirmajaa auto: "; cin>>K;
  cout<<"Ievadi cik cilveki var iekapt otrajaa auto:"; cin>>M;
   x=(N/K) && (N/M);

got so far :/
Last edited on
your if statement is incorrect, you need to break up the statement even more than that:

if(n > 0 && n < 2147483648 && k > 0 && k < 100 && m > 0 && m > 100)

dont use commas, it is just one continuous if statement.

x=(N/K) && (N/M);

the second statement does nothing, && N/M is not assigned to a variable. It would be the same as writing 4+3 in a program(it isn't assigned to anything, so nothing will change).

how far into the course are you guys? have you learned while loops yet?

Topic archived. No new replies allowed.