Write a C program to check wheather the given number is Postive or Negative?
#include <stdio.h>
#include <conio.h>
main()
{
int n;
clrscr();
printf("Enter the value for n: ");
scanf("%d",&n);
if (n>0)
printf("n is Positive.");
else
printf("n is Negative.");
getch();
}
Output:
Enter the value for n: 10
Positive
Enter the value for n: -10
Negative
Write a C program to find the biggest among two numbers?
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the values for a and b: ");
scanf("%d" %d",&a,&b);
if (a>b)
printf("a is biggest.");
else
printf("b is biggest.");
getch();
}
Output:
Enter the value for a: -10
Enter the value for b: 5
b is biggest.
Enter the value for a: 5
Enter the value for b:-10
a is biggest.
Write a C program to find the smallest among two numbers?
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the values for a and b: ");
scanf("%d" %d",&a,&b);
if (a<b)
printf("a is smallest.");
else
printf("b is smallest.");
getch();
}
Output:
Enter the value for a: -10
Enter the value for b: 5
a is smallest.
Enter the value for a: 5
Enter the value for b:-10
b is smallest.
#include <stdio.h>
#include <conio.h>
main()
{
int n;
clrscr();
printf("Enter the value for n: ");
scanf("%d",&n);
if (n>0)
printf("n is Positive.");
else
printf("n is Negative.");
getch();
}
Output:
Enter the value for n: 10
Positive
Enter the value for n: -10
Negative
Write a C program to find the biggest among two numbers?
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the values for a and b: ");
scanf("%d" %d",&a,&b);
if (a>b)
printf("a is biggest.");
else
printf("b is biggest.");
getch();
}
Output:
Enter the value for a: -10
Enter the value for b: 5
b is biggest.
Enter the value for a: 5
Enter the value for b:-10
a is biggest.
Write a C program to find the smallest among two numbers?
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
clrscr();
printf("Enter the values for a and b: ");
scanf("%d" %d",&a,&b);
if (a<b)
printf("a is smallest.");
else
printf("b is smallest.");
getch();
}
Output:
Enter the value for a: -10
Enter the value for b: 5
a is smallest.
Enter the value for a: 5
Enter the value for b:-10
b is smallest.