In C, Not C++ or C Sharp and only using the For loops Create a program that only
ID: 3889345 • Letter: I
Question
In C, Not C++ or C Sharp and only using the For loops
Create a program that only uses 3 variables to accomplish all of the following: prompt the user for an integer and reads it, . uses for statement(s) to calculate and print results for: o Count the number of digits in the input entered and displays it, o Calculate the xth triangular number and display it, Calculate the power of x ^ (#of digits) and display it, o Display your entered values in reverse, o and displays a thank you message at the end of the program. All as follows (including complete and coherent sentences): This program will: 1. Take your input Cinteger), x 2. Count the number of digits (in the input entered, x) and display it, 3. Calculate the xth triangular number and display it, 4, Calculate the powe r of x ^ (#of digits) and display it, S. Display your entered values in reverse. ea NM 1. Please enter a number: 123 2. The number you entered has 3 digits. 3. The 123 triangular number is 7626. 4. 123 ^ 3 = 1860867. 5. The 123 digits in reverse are 3.2.1. fax: 575-646-6107Explanation / Answer
#include <stdio.h>
#include <math.h>
int main()
{
int i,j=1,k=1,n;
int temp, remainder, reverse = 0,count=0,result=1;
//int x,result;
printf(" Please Enter a number:");
scanf("%d",&n);
temp=n;
while(temp != 0)
{
temp /= 10;
++count;
}
printf("You Have Entered %d digits",count);
printf(" ");
for(i=1;i<=n;i++)
{
if(i==n)
{
printf("%d Traingular Number is %d ",n,k);
break;
}
j=j+1;
k=k+j;
}
printf(" ");
int x=1;
while(x<=count){
result=result*n;
x++;
}
printf(" %d ^ %d is: %d",n,count,result);
printf(" ");
while(n != 0)
{
remainder = n%10;
reverse = reverse*10 + remainder;
n /= 10;
}
printf("Reversed Of the Number = %d ", reverse);
printf(" ");
return 0;
}