-->

Facebook

Jasper Roberts - Blog

Friday, April 10, 2015

Write a function find out maximum out of three numbers.

#include<stdio.h>
#include<conio.h>

int largest()
{
int n1, n2, n3;
printf("\n ENTER THREE NUMBERS:");
scanf("%d",&n1);
printf("\n ENTER THREE NUMBERS:");
scanf("%d",&n2);
printf("\n ENTER THREE NUMBERS:");
scanf("%d",&n3);
printf("\n\n\t THE BIGGEST NUMBER IS: ");

if( (n1 > n2) && (n1 > n3) )
printf("%d", n1);
else if(n2 > n3)
printf("%d", n2);
else
printf("%d", n3);

printf("\n\n\t THE SMALlEST NMBER IS…: ");
if( (n1 < n2) && (n1 < n3) )
printf("%d", n1);
else if(n2 < n3)
printf("%d", n2);
else
printf("%d",n3);
 return 0;

}

void main()
{
clrscr();
largest();
getch();
}
Largest Numbers

Write a function program to add first N numbers.



#include <stdio.h>
#include <conio.h>

void main()
{
    int n;
clrscr();
numbers(n);
getch();
}

int numbers(int n)
{
int sum = 0, i;

   printf("Enter the number of integers you want to add\n");
   scanf("%d", &n);

   for (i = 1; i <= n; i++)
   {
      sum = sum + i;
   }

   printf("Sum of entered integers = %d\n",sum);

   return 0;
}