0% found this document useful (0 votes)
14 views1 page

PRGRM 1

This C program performs basic arithmetic operations based on user input. It prompts the user to enter an operator and two operands, then calculates the result using a switch statement. Additionally, it checks if the integer part of the result is positive or negative and whether it is even or odd.

Uploaded by

athulatk6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

PRGRM 1

This C program performs basic arithmetic operations based on user input. It prompts the user to enter an operator and two operands, then calculates the result using a switch statement. Additionally, it checks if the integer part of the result is positive or negative and whether it is even or odd.

Uploaded by

athulatk6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>
void main()
{
char Operator;
float num1,num2,result = 0;
printf("Please Enter an Operator(+,-,*,/):");
scanf("%c",&Operator);
printf("\n Please Enter the values for two Operands:num1 and num2:");
scanf("%f%f",&num1,&num2);
switch(Operator)
{
case '+': result=num1+num2;
break;
case '-': result=num1-num2;
break;
case '*': result=num1*num2;
break;
case '/': result=(float)num1/(float)num2;
break;
default: printf("\n You have entered an invalid operator");
}
printf("\n The result of %.2f %c %.2f = %.2f",num1,Operator,num2,result);

int r = result;
if(r%2==0 && r>=0)
{
printf("\n The result is positive and even");
}else if(r%2==0 && r<0)
{
printf("\n The result is negative and even");
}else if(r%2!=0 && r>=0)
{
printf("\n The result is positive and odd");
}else if(r%2!=0 && r<0)
{
printf("\n The result is negative and odd");
}
getch();
}

You might also like