• To accept integer and display the result by multiplying it with 3.
• To accept two integers and display larger number of them.
To check whether, user entered number is positive or negative.
Answers
The general logics for the questions are as follows:
Question 1: To accept integer and display the result by multiplying it with 3.
Multiply()
{ scanf("%d", &n);
result= n*3;
printf("%d", result);
}
Question 2: To accept two integers and display larger number of them.
larger()
{ scanf("%d %d", a,b);
if (a>b)
printf("a is greater");
else
printf("b is greater");
}
Question 3: To check whether, user entered number is positive or negative.
positive()
{ scanf("%d", n);
if (n>0)
printf("The no. is positive");
else
printf("The no. is negative");
}
┏─━─━─━─━∞◆∞━─━─━─━─┓
✭✮ӇЄƦЄ ƖƧ ƳƠƲƦ ƛƝƧƜЄƦ✮✭
┗─━─━─━─━∞◆∞━─━─━─━─┛
The general logics for the questions are as follows:
Question 1: To accept integer and display the result by multiplying it with 3.
Multiply()
{ scanf("%d", &n);
result= n*3;
printf("%d", result);
}
Question 2: To accept two integers and display larger number of them.
larger()
{ scanf("%d %d", a,b);
if (a>b)
printf("a is greater");
else
printf("b is greater");
}
Question 3: To check whether, user entered number is positive or negative.
positive()
{ scanf("%d", n);
if (n>0)
printf("The no. is positive");
else
printf("The no. is negative");
}