|
Answer» am to check whether a given number is a Trendy Number or Not.Language used : C programming.Program :#include int MAIN(){ int a,b,count; printf("Enter a number : "); scanf("%d",&a); //finding the number of numbers present in the number in variable 'a'. while (a != 0) { a /= 10; ++count; } if(count!=3) { printf("%d is NOT a trendy number", a); } else { b = (a / 10) % 10 ; // b has the middle number now. if(b%3==0) { printf("%d is a trendy number", a); } else { printf("%d is NOT a trendy number", a); } } RETURN 0;}Inputs and outputs :Input 1 :123Output 1 :123 is NOT a trendy numberInput 2 :261Output 2 :261 is a trendy numberInput 3 :79725Output 3 :79725 is NOT a trendy numberExplanation :Declare the necessary variables. You can declare them as the code progresses further, too.Ask user to input an integer which we should find whether it is a tendy number or not.Once inputted, check the count of the number of digits present in the number.If the count is not equal to 3, print a statement stating that the given number is not a trendy ONE.Else, TAKE out the middle value of the three digit number and check whether it LEAVES a remainder 0 on dividing with 3.If yes, print that it is a trendy number, else print that it is not a trendy one. That's it!Learn more :1) Palindrome program in C.brainly.in/question/23725802) Define programming in C++brainly.in/question/17432354
|