You are on page 1of 9

PROGRAMMING LANGUAGES

CT-153
Lecture # 08
IF statements in R
• IF
• IF-Else
• IF—ELSE IF — ELSE (IF ELSE Ladder)
IF STATEMENT
Syntax of if statement
IF STATEMENT
IF ELSE STATEMENT
Syntax of if statement
IF ELSE STATEMENT
IF ELSE STATEMENT
• Write an R program to check whether a number is even or odd.
• Write an R program to find maximum between two numbers.
• Write an R program to calculate profit or loss, ask user total cost and
revenue generated and calculate profit or loss.
• Write an R program to input angles of a triangle and check whether
triangle is valid or not.
if…else Ladder
if…else Ladder
• Write an R program to check whether a number is negative, positive
or zero.
• Design a simple calculator that can add, subtract, multiply or divide 2
numbers, using if else statement
• Write an R program to check whether the triangle is equilateral or
scalene triangle.
• Write a C program to input marks of five subjects Physics, Chemistry,
Biology, Mathematics and Computer. Calculate percentage and grade
according to following:

You might also like