Discussion Locked

please help me solve this program

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
the program takse from the user any number between 0 - 32767 and displays it in a written form , then calcu;ates the sum of digits, and find the min and max numbers

2 replies

by obadare

try this: [java]
JTextField tf;
String input=tf.getText();
Integer[] ia=new Integer[input.length()];
int[] inta=new int[ia];
for(int i=0;i

by mmmova

/* a possible solution in tc3*/
*By MMM
*Hope this will solve your problem
*/

#include
#include

void main()
{
int sum,min,max,numIn,num[],i=0;

printf("Enter a value between 0 and 32767: ");
scanf("%d, &num);//user input

//if invalid input....
//take input again
while(num<=0 || num>32767)
{
printf("Enter a value between 0 and 32767: ");
scanf("%d, &num);
}

while(num>0 && num<32767)
{
num[i]=num%10;
sum+=num[i];
min=num[0];
max=num[0];
if(num[i]max)max=num[i];
++i;
num/=10;

}
printf("The sum of %d digits is : ",i,sum);
printf("The max digit is : ",max);
printf("The min digit is : ",min);

getch();
}

This discussion is closed to new replies.