Maximum value finding code in C programming language. This largest value calculation code is based on integer value detecting. Variables and functions also declared as an Integer. This sample source code is ease to use. The code is given below,
FINDING MAXIMUM VALUE IN C
This C program is used to find the maximum value number in the list of values entered by user. Program is based on conditional statements of basic if ((num>max)).
CODE SNIPPET:
Q: Write a C program to find maximum integer value from the given numbers.
/* Tittle : Maximum Value Program
© http://students3k.com - Karthikh Venkat
*/
//Header files
#include<stdio.h>
#include<stdarg.h>
#include<conio.h>
//Global variables
int findmax(int totali,...);
int main()
{
int max; //Program variables
clrscr(); //Function to clear previous function
max=findmax(6,23,45,24,2,56,43); //Maximum value
printf("\n%d",max);//Display function
max=findmax(8,23,45,24,2,56,43,82,67);
printf("\n%d",max);
getch();
return 0;
}
int findmax(int total,...)
{
va_list ptr;
int i,max,num;
va_start(ptr,total);
max=va_arg(ptr,int);
for (i=2;i<=total;i++) //Looping statement
{
num=va_arg(ptr,int);
if (num>max)
max=num;
}
return max;
}