C Foundation

What is C? C Compiler Installation C Extensions C Compiler C Interpreter C Program Structure

C Basics

C Keywords C Data Types C Identifiers C Variables C Constant C Escape Sequences C Constant and Volatile C Typecast

Operators

What is Operator C Comma Operator C Arithmetic Operators C Relational Operators C Logical Operators C Bitwise Operators C Conditional Operators C : : Operator C Operator Priority

Basic IO's

Basic IO's C Formatted Functions C Unformatted Functions C Common Functions

Control Statements

What is Control Statement C if Statement C if else Statement C Nested if Statement C Else if Statement C Break Statement C Continue Statement C Switch Statement C Goto Statement

Looping

What is Control Loop C for Loop C Nested for Loop C while Loop C Nested while Loop C do while Loop C Nested do while loop

Functions

What is Function C User Defined Functions C Recursion C Passing Parameters

Scope

Scope C Local Scope C Global Scope

Storage Classes

What is Storage Class C Auto C Extern C Static C Register

Array

What is Array C One Dimensional Array C Two Dimensional Array C Multi Dimensional Array C Arrays Of Strings

String

What is String C String Functions

Pointer

What is Pointer C Pointers Arithmetic C Pointer to Pointer C Pointers and Arrays C Pointers and Strings C Pointer to Functions Void Pointers Null Pointers C Null and Void Pointer

Structure

What is Structure C Struct within Struct C Array within Structure C Pointer to Structure C Structure and Function C Enum C Bitfield Structure C Type def

Union

What is Union

Files

What is File C read a file C write a file C File Handling C Error Handling C Low Level Disk I/O C Other file functions

Memory Allocation

What is Memory Allocation C Malloc() C Calloc() C Free() C Realloc() C Coreleft()

C Reference

All ASCII Code Basic C Questions

C Interview

C Interview Sets All Star Patterns All Number Patterns All Alphabet Patterns All Series Patterns
The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Biggest Number

Let's do some magic with our friends using our powerful computer. Let us ask one of our friend to enter two numbers. Our computer must display the biggest number among those, Here is a code to display the biggest of two numbers using C programming.

Biggest Number in C

C Program - Biggest of Two Numbers

biggest-number.c
#include <stdio.h>
int main()
{
int num1, num2;
printf("\nEnter the number 1 : ");
scanf("%d",&num1);
printf("\nEnter the number 2 : ");
scanf("%d",&num2);
printf("\nBiggest number : %d ", num1 > num2? num1:num2);
return 0;
}
Enter the number 1 : 5
Enter the number 2 : 10
Biggest number : 10

Note:

Here we get two numbers from our user using the variables num1 and num2 then by using conditional operator we check for biggest number.

C Program - Biggest of n Numbers - Easy

Here we used 5 variables to display biggest of n numbers using C programming.

biggest-n-number-easy.c
#include <stdio.h>
int main()
{
int num, limit, i, temp1, temp2;
printf("\n Enter the limit : ");
scanf("%d",&limit);
for(i = 0; i < limit; i++)
{
printf("\nEnter number %d :",i+1);
scanf("%d",&num);
if(i == 0)
temp1 = num;
else
temp2 = num;
if(temp2 > temp1 )
{
temp1 = num ;
}
}
printf("The biggest number is %d",temp);
return 0;
}
Enter the limit : 5
Enter number 1 : 55
Enter number 2 : 12
Enter number 3 : 17
Enter number 4 : 72
Enter number 5 : 44

Biggest number is 72

Note:

First of all, we ask our user to enter the limit. Then by using the limit in for loop, we get that n numbers. while getting 1st number we stored it in our temporary variable temp1 and we try to maintain the biggest number in our temp1 variable. Then from 2nd value of n numbers we stored in our second temporary variable temp2 and finally we display a value stored in our temporary variable temp1, which is the biggest number of n numbers.

C Program - Biggest of n Numbers - Medium

Here we used 4 variables to display biggest of n numbers using C programming.

biggest-n-number-med.c
#include <stdio.h>
int main()
{
int i, limit, num, temp = 0;
printf("Enter the limit : ");
scanf("%d",&limit);
printf("\nEnter %d numbers\n",limit);
for(i=0; i < limit; i++)
{
printf("\nEnter number %d :",i+1);
scanf("%d",&num);
if(num > temp)
temp = num;
}
printf("The biggest number is %d",temp);
}
Enter the limit : 5
Enter number 1 : 55
Enter number 2 : 12
Enter number 3 : 17
Enter number 4 : 72
Enter number 5 : 44

Biggest number is 72

Note:

First of all, we declare and initiate the variable temp = 0. we ask our user to enter the limit. Then by using the limit in for loop, we get that n numbers. For everytime the user enter the number, we check the biggest number using our temp variable. If the user entered number is bigger than our value in temp variable, then we replace our current value in temp variable with that bigger number. finally we display a value stored in our temporary variable temp, which is the biggest number of n numbers.

C Program - Biggest of n Numbers - Advanced

Here we used 3 variables to display biggest of n numbers using C programming.

biggest-n-number-med.c
#include <stdio.h>
int main()
{
int limit, num, temp = 0;
printf("Enter the limit : ");
scanf("%d",&limit);
printf("\nEnter %d numbers\n",limit);
while(limit--)
{
scanf("%d",&a);
if(num > temp)
temp = num;
}
printf("The biggest number is %d",temp);
return 0;
}
Enter the limit : 5
Enter number 1 : 55
Enter number 2 : 12
Enter number 3 : 17
Enter number 4 : 72
Enter number 5 : 44

Biggest number is 72

Note:

We ask our user to enter the limit. Then by using the limit following with decrement operator in while loop, we get all n numbers from our user. Then we use temp variable to check for biggest number and then display the value in temp variable when the condition in while loop is false i.e ) 0

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report

We to update you