Hi!
I am learning C programming and I need some help. In my project I have to enter n numbers and find the smallest and the largest number. AND I DID THIS!
But I can not sum up this two values! Could you please help me?
Hi!
I am learning C programming and I need some help. In my project I have to enter n numbers and find the smallest and the largest number. AND I DID THIS!
But I can not sum up this two values! Could you please help me?
You did what?
Show us the code you have so far.
I am sorry, I am the new comer.Next time I will be more careful.
Code:#include<stdio.h> main() { int n,m,i,min,max; printf("Please enter a positive integer:"); scanf("%d",&n); printf("Enter integers:"); scanf("%d",&m); max=m; min=m; for(i=2;i<=n;i++) { scanf("%d",&m); if(m<min) min=m; if(m>max) max=m; } printf("The smallest number is %d\nThe greatest number is %d\n",min,max); scanf("%d %d",&min,&max); printf("The sum is : %d\n",min+max); }
The sum part can t work. Please help me!
What is line 22 supposed to do? You're overriding your min and max there. Get rid of that and your summation should work correctly.
Thank you so much, Dennis.cpp. It works I am so happy!!!!!
Do you understand why and what's different now? What had you been trying to achieve with that line 22?
Right.