Write A C Program To Evaluate R X y + (Y+3) (x-2)
Write A C Program To Evaluate R X y + (Y+3) (x-2)
}
/* please note῀ symbol key is available on top left hand corner and it means complement*/
14. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND FIND THE LARGEST OF TWO NUMBERS USING A
FUNCTION
#include<stdio.h>
int A,B;
void Large();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Large();
}
void Large()
{
if (A==B)
printf("\nBoth are equal");
else
{
if(A>B)
printf("\n A= %d is the largest", A);
else
printf("\n B= %d is the largest", B);
}
}
15. WRITE A C PROGRAM TO ACCEPT TWO NUMBERS AND CHECK IF THEY ARE ODD/EVEN USING A
FUNCTION
#include<stdio.h>
int A,B;
void Odd_Even();
main()
{
printf("Enter any two integers");
printf("\nA=");
scanf("%d",&A);
printf("\nB=");
scanf("%d",&B);
Odd_Even();
}
void Odd_Even()
{
if(A%2==0)
printf("\n A=%d is an Even number", A);
else
printf("\n A=%d is an Odd number",A);
if(B%2==0)
printf("\n B=%d is an Even number", B);
else
printf("\n B=%d is an Odd number",B);
}
16. WRITE A C PROGRAM TO ACCEPT A NUMBER AND CHECK IF IT IS PRIME
#include<stdio.h>
int N,i;
main()
{
printf("Enter any integers");
printf("\nN=");
scanf("%d",&N);
switch(N)
{
case 1: {
printf("The number 1 is a Prime number");
break;
}
case 2: {
printf("The number 2 is a Prime number");
break;
}
default:
{
for(i=2;i<=N-1;i++)
{
if (N%i==0)
{
printf("\n N= %d is not a prime number",N);
break;
}
}
if (i==N)
printf("\n N= %d is a prime number", N);
}
}
}