Another approch to find MAX

/*
************************************************************************
* Name: maximum finder.cpp
************************************************************************
*
*
* Authors: Sourav Halder [A Student of class XI at The School- ‘Chakdha Ramlal Academy’.]
*
* Souvik Halder [Brother of Sourav Halder.]
*
*
*
* Checked By: Chandan Chakrabarti [A teacher at ‘Chakdha Ramlal Academy’.]
*
* Dedicated to: Dennis M. Ritchie
*
* Date: 03/01/12 13:22
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. from http:// fsf.org
* **********************************************************************
*/
#include
#include
main()
{
/*
Declaration Part:
Here we have used Array for our Program, Pointer can also be used here.The size of
the array can also be increased or decreased according to the strenth of the compilor.
*/
int i;
float n,a[10000],sum=0,count=0,average,divider;
printf(“You want to compare how much numbers: “);
scanf(“%f”,&n);
divider=n;
// Inputing numbers in the array.
for (i=1;i<=n;i++)
{
printf(" Enter No.%d: ",i);
scanf("%f",&a[i]);
}
// Sum of the inputed numbers is insurted into the variable 'sum'.
for(i=1;i<=n;i++)
{
sum+=a[i];
}
// The statements in 'while' loop is used to stop the work of the loop when maximum number has been printed.
while((divider!=1)&&(divider!=0))
{
average=sum/divider;
sum=0;
for(i=1;iaverage)
{
sum+=a[i];
// Counting that how much numbers have entered through the “if” statement.
count++;
}
}

divider=count;
// If only one number have passed through the “if” statement then the ‘sum’ is the maximum number.
if(divider==1)
{
printf(“\nThe maximum number is: %f\n”,sum);
}
/* If any number have not passed through the “if” statement then there must be
more than one maximum number who are equal.
So that the average of the numbers is equal to them. */
if(divider==0)
{
printf(“\nThe maximum number is: %f\n”,average);
}
/* ‘count’ is assigned the value ‘0’ for counting again if the ‘while’ loop still work. */
count=0;
}
printf(“\nPress ANY KEY to terminate the program.\n”);
getch();
return 0;
}

Posted in Uncategorized | Tagged | Leave a comment

C by sourav

/*
************************************************************************
* Name: maximum finder.cpp
************************************************************************
*
*
* Authors: Sourav Halder [A Student of class XI at The School- ‘Chakdha Ramlal Academy’.]
*
* Souvik Halder [Brother of Sourav Halder.]
*
*
*
* Checked By: Chandan Chakrabarti [A teacher at ‘Chakdha Ramlal Academy’.]
*
* Dedicated to: Dennis M. Ritchie
*
* Date: 03/01/12 13:22
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. from http:// fsf.org
* **********************************************************************
*/
#include
#include
main()
{
/*
Declaration Part:
Here we have used Array for our Program, Pointer can also be used here.The size of
the array can also be increased or decreased according to the strenth of the compilor.
*/
int i;
float n,a[10000],sum=0,count=0,average,divider;
printf(“You want to compare how much numbers: “);
scanf(“%f”,&n);
divider=n;
// Inputing numbers in the array.
for (i=1;i<=n;i++)
{
printf(" Enter No.%d: ",i);
scanf("%f",&a[i]);
}
// Sum of the inputed numbers is insurted into the variable 'sum'.
for(i=1;i<=n;i++)
{
sum+=a[i];
}
// The statements in 'while' loop is used to stop the work of the loop when maximum number has been printed.
while((divider!=1)&&(divider!=0))
{
average=sum/divider;
sum=0;
for(i=1;iaverage)
{
sum+=a[i];
// Counting that how much numbers have entered through the “if” statement.
count++;
}
}

divider=count;
// If only one number have passed through the “if” statement then the ‘sum’ is the maximum number.
if(divider==1)
{
printf(“\nThe maximum number is: %f\n”,sum);
}
/* If any number have not passed through the “if” statement then there must be
more than one maximum number who are equal.
So that the average of the numbers is equal to them. */
if(divider==0)
{
printf(“\nThe maximum number is: %f\n”,average);
}
/* ‘count’ is assigned the value ‘0’ for counting again if the ‘while’ loop still work. */
count=0;
}
printf(“\nPress ANY KEY to terminate the program.\n”);
getch();
return 0;
}

Posted in Uncategorized | Leave a comment

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.
Posted in Uncategorized | 1 Comment