What is the function(in C) to find the minimum value from a loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the function(in C) to find the minimum value from a loop?

27th Oct 2019, 1:22 PM
Sazid Alam
Sazid Alam - avatar
5 Answers
+ 1
#include<stdio.h> int main(){ int n, x, y,i,s,a; scanf("%d", &n); for(i=n; i>=1; i--){ if(n%i==0){ x=n/i; y=2*(x+i); }} printf("%d\n",y); return 0; } This is my code. From here I want the minimum value of y.
27th Oct 2019, 1:50 PM
Sazid Alam
Sazid Alam - avatar
+ 1
Your code is able to find out only in one case(3 numbers). I wanted a code for any amount of numbers.
27th Oct 2019, 5:58 PM
Sazid Alam
Sazid Alam - avatar
+ 1
👍👍
27th Oct 2019, 6:04 PM
Sazid Alam
Sazid Alam - avatar
+ 1
It's ok. Thanks.
27th Oct 2019, 6:18 PM
Sazid Alam
Sazid Alam - avatar
0
Hi
28th Oct 2019, 10:00 PM
Malumi Temmy
Malumi Temmy - avatar