You are on page 1of 4

1. WAP TO DISPLAY STUDENT INFORMATION.

name <- "jay"


id <- "21IT466"
mob <- "7861008521"
cat("name",name,"\n")
cat("id ",id ,"\n")
cat("mob ",mob,"\n")

OUTPUT:

2. WAP TO MAKE CALCULATOR.

a <- as.numeric(readline(prompt="Enter the first number:"))


b <- as.numeric(readline (prompt="Enter the second number:"))
c <- readline(prompt="enter the operator")

d=switch(
c,
"+"=a+b,
"-"=a-b,
3. WAP TO CHECK GIVEN NUMBER IS ODD OR EVEN

a <- as.numeric(readline(prompt="enter the number"))

if(a%%2==0){
print("number is even")

}else{
print("number is odd")
}

OUTPUT:
4.WAP TO CHECK % BELONG TO WHICH CLASS USING IF ELSE.

a <- as.numeric(readline(prompt="enter the number"))


if(a>70){
cat("you are belong to distintion")
}else if(a>60){
cat("you are belong to first class")
}else if(a>45){
cat("you are belong to second class")
}else{
cat("you are belong to pass")
}

OUTPUT:

5.WAP TO PRINT FIRST FIVE FIBO.

a <-0
b<-1
cat(a)
cat(" ",b)
count <- 2
while(count<=4)
{
c<-a+b
a<-b
b<-c
cat(" ",c)
count <-count+1
}

OUTPUT:

6.check the number is perfect or not.

a <- as.numeric(readline(prompt="enter the number"))

i=1
s=0

while(i<a){
if(a%%i==0){
s=s+i
}
i=i+1
}
if(s==a){
cat("Number is perfect" , a)
}else{
cat("Number is not perfect" , a)
}

Output:

You might also like