#include<stdio.h>
main()
{
int i,j,k,n;
printf("Enter the number of lines");
scanf("%d",&n);
for(i=n;i>=0;i--)
{
for(k=n-i;k>0;k--)
{
printf(" ");
}
for(j=i-1;j>=0;j--)
{
printf("%2d",i);
}
printf("\n");
}
}
ALGORITHM REVERSEINPUT (string)"STRINGLENGTH() would be a function that returns the lenght of the string"FOR (i = STRINGLENGTH(string); i >= 0; i--) BEGINDISPAY (string[i])END FOREND REVERSE
public static void main(String[] args) { int val = 100; int val1 = 50; System.out.println("Number of digits in " + val + " is: " + new String(val + "").length()); System.out.println("Number of digits in " + val1 + " is: " + new String(val1 + "").length()); }
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
public class StringReverseExample { public static void main(String[] args) { int num=1001; int n=num, rev; while(num!=0) { int d=num%10; rev= (rev*10)+d; num=num/10; } System.uot.println(rev); } }
It appears that only single digit numbers work (0 thru 9)
Some numbers that you can get when you reverse the digits and they are still prime numbers are: 403 ÷ 13 = 31 2,701 ÷ 37 = 73 1,207 ÷ 17 = 71
20
# include<stdio.h> # include<conio.h> void main() { int n; printf("enter the number"); scanf("%d",&n); while(n>0) { s=n%10; printf("%d",s); n=n/10; } getch(); }
72 reverse the digits divide by 3 = 24
No. For example, 1/3 = 0.333333333...(repeats forever). The calculator can only display finitely many digits.
Instead of reading the numbers from left to right (1234) read them from right to left (4321).
61 42 56 89
No. An irrational number is one that does not repeat or finish, and a calculator cannot display millions of digits like an irrational number would have.
This happens because the contribution of the smaller number is lost in the trailing decimal digits. Suppose you had a calculator that could display 10 digits. Suppose you tried to add 123,456.789 and 0.000 000 12 The true answer is 123,456.789 000 12 but, since you can only display 10 digits, the answer shows as 123,456.7890 which is the larger number. The exact details will depend on the number of displayed digits.
10 digits are numbers in the billions.
There is no upper limit to numbers, there are some astronomical numbers with more digits than the universe has atoms (See Graham's number) used in math. On many calculators, the largest number it can calculate is limited by the number of digits your calculator can display. If it can display 12 digits, the largest number you can calculate on it is 999,999,999,999. The scientific calculators which support scientific notation can usually calculate numbers up to 9.999999 x 1099. Some high-tech ones can go up to 9.99999 x 10999. On the other hand, I use a professional program used to crunch numbers and the largest number it says it can express is 1.920224672692357 x 10646456887 (or 22147483296). Not that I think I would need to use such a large number any time soon.
There are 5 numbers of 1 digit, 25 numbers of 2 digits, and 75 numbers of 3 digits. This makes 105 numbers in all.