Write R Program That Determine Whether The Given Number by The User Is Odd or Even. Solution
Write R Program That Determine Whether The Given Number by The User Is Odd or Even. Solution
SOLUTION
if((num %% 2) == 0) {
print(paste(num,"is Even"))
} else {
print(paste(num,"is Odd"))
2.VAT has different rate according to the product purchased. Imagine we have three different
kinds of products with different VAT applied:
We can write a chain to apply the correct VAT rate to the product a customer bought.
SOLUTION
price <- 10
if (category =='A'){
cat('A vat rate of 8% is applied.','The total price is',price *1.08)
} else {
3.Create a function that takes back bearing and included angle from the user
SOLUTION
# F.B = B.B + Included angle {Sum smaller than 180 then add 180 and sum greater than 180 and lesser
than 540 then subtract 180 ; if sum greater than 540 than subtract by 540}.
bearing <-function ()
(Unable to solve )
4.Create a function that takes horizontal coordinates of two points and
gives the whole circle bearing of a line connecting those two points as an output.
(Unable to solve)
5.Write R program that takes your name as an input and output each letter of your name as an
output.
SOLUTION
x <-nchar(name)
for ( i in x) {
print(output)
i = i+1
6.Give one example that uses break statement within while loop.
SOLUTION
while (i <= 6) {
if (i==4)
break;
print(i*i)
i = i+1
7.Give one example that uses next statement within for loop.
SOLUTION
if (val %% 2 != 0) {
next