The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs

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.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

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

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

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.

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); }

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.

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; }

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

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

© Copyright 2018