Describe if statement. write an if statement to multiply even numbers by 3 and odd numbers by 4
Answers
Answered by
0
if statements aree used in C++ when there is condition applied
kritisodhi123:
please explain
Answered by
1
When we need to execute a block of statements only when a given condition is true then we use if statement.
Ex:
#include<stdio.h>
#include<conio.h>
int main()
{
int result;
clrscr();
printf("Enter any number:");
scanf("%d",&result);
if(result%2==0)
{
printf("The output is : %d", result * 3);
}
else
{
printf("The output is : %d",result * 4);
}
return 0;
}
Hope this helps!
Ex:
#include<stdio.h>
#include<conio.h>
int main()
{
int result;
clrscr();
printf("Enter any number:");
scanf("%d",&result);
if(result%2==0)
{
printf("The output is : %d", result * 3);
}
else
{
printf("The output is : %d",result * 4);
}
return 0;
}
Hope this helps!
Similar questions
Social Sciences,
7 months ago
Biology,
7 months ago
English,
7 months ago
Math,
1 year ago
Chemistry,
1 year ago
Environmental Sciences,
1 year ago