Everyone i am ajay Verma and i answer this question, Write this programe in note pad:-
using System;
class MyClass
{
public static void Main(string [] args)
{
int n,d,result=1,sum=0;
Console.WriteLine("Enter any Number");
n=Convert.ToInt32(Console.ReadLine());
for(;n>0;)
{
d=n%10;
Console.WriteLine(d);
n=n/10;
}
}
}
#include
#include
#include
//My name is Prince Fred in Uganda, East Africa
// please if you like this, e-mail me atmuteesafred@yahoo.com or,
// call +256-712-134-996 to make me your friend.
// I used borland c++ 4.5 to compile.
void pw(int,char[]);
char *one[]={" "," one"," two"," three"," four"," five"," six"," seven",
"eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"};
void main()
{
int n;
clrscr();
printf("Enter any 3 digit no: ");
scanf("%d",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/100)," hundred and");
pw((n%100)," ");
}
getch();
}
void pw(int n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
if(n)
printf("%s ",ch);
}
#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
const int s = 3;
int a[s];
int x,y,z;
for (int i=0; i<s; i++)
cin >> a[i];
x = a[0];
y = a[1];
z = a[2];
i = 0;
cout<<x<<y<<z;
cout<<"n";
while(1){
a[s] = a[i];
if (i != s - 1){
a[i] = a[i+1];
a[i+1] = a[s];
}
else {
a[i] = a[0];
a[0] = a[s];
i=-1;
}
i++;
if (a[0] z)
break;
for (int j = 0; j < s; j++)
cout<<a[j];
cout<<"n";
}
getch();
}
When dealing with a combination (in the mathematical sense), the order of the elements does not matter. Thus {1, 2, 3} is the exact same combination as {3, 2, 1}. The latter is known as a permutation (of the combination). For any given 3-digit combination there are 6 permutations, however if any two of the three digits are the same digit, then there are only 3 permutations, and if all three digits are the same then there can be only one permutation.
The following function will print all possible permutations of any 3 digits.
void print_permutations (int a, int b, int c) {
// sort digits in ascending order
if (b<a) a^=b^=a^=b; if (c<b) c^=b^=c^=b; if (b<a) a^=b^=a^=b;
if (a==b && b==c) { // all 3 digits match
printf ("{%d, %d, %d}\n", a, b, c);
} else if (a==b) { // first two digits match
printf ("{%d, %d, %d}\n", a, b, c);
printf ("{%d, %d, %d}\n", a, c, b);
printf ("{%d, %d, %d}\n", c, a, b);
} else if (b==c) { // last two digits match
printf ("{%d, %d, %d}\n", a, b, c);
printf ("{%d, %d, %d}\n", b, a, c);
printf ("{%d, %d, %d}\n", b, c, a);
} else { // all digits unique
printf ("{%d, %d, %d}\n", a, b, c);
printf ("{%d, %d, %d}\n", a, c, b);
printf ("{%d, %d, %d}\n", b, a, c);
printf ("{%d, %d, %d}\n", b, c, a);
printf ("{%d, %d, %d}\n", c, a, b);
printf ("{%d, %d, %d}\n", c, b, a);
}
}
To test the function, use the following:
int main () {
int a, b, c;
printf ("Enter three digits: ");
scanf ("%d %d %d", &a, &b, &c);
print_permutations (a, b, c);
return 0;
}
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
The tricky part is getting the individual digits. There are basically two ways to do this: 1) Convert the number to a string, and use string manipulation to get the individual digits. 2) Repeatedly divide the number by 10. The digit is the remainder (use the "%" operator). To actually get the highest digit, initially assume that the highest digit is zero (store this to a variable, called "maxDigit" or something similar). If you find a higher digit, replace maxDigit by that.
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()); }
The radix refers to the base of a number system: the total number of possible digits. The decimal number system that we all use is base ten, as it has ten distinct digits (0,1,2,3,4,5,6,7,8,9). Commonly used bases in computing include binary, octal, and hexadecimal, which have two, eight, and sixteen digits, respectively.
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
128
0000-9999 (10x10x10x10 or 104) = 10,000 possible combinations allowing for repeated digits. If you are not able to repeat digits then it's 10 x 9 x 8 x 7 or 5,040 possible combinations without repeated digits.
There are: 30C5 = 142,506
10 possible numbers on each wheel equals 10x10x10 or 1000 combinations possible.
If the digits can repeat, then there are 256 possible combinations. If they can't repeat, then there are 24 possibilities.
Since a number can have infinitely many digits, there are infinitely many possible combinations.
9x8x7x6x5x4x3x2x1 or 9! which equals 362880 possible combinations if no digits are repeated
You can make: 1 combination containing 0 digits, 7 combinations containing 1 digits, 21 combinations containing 2 digits, 35 combinations containing 3 digits, 35 combinations containing 4 digits, 21 combinations containing 5 digits, 7 combinations containing 6 digits, and 1 combinations containing 7 digits. That makes 2^7 = 128 in all.
There are different numbers of combinations for groups of different sizes out of 9: 1 combination of 9 digits 9 combinations of 1 digit and of 8 digits 36 combinations of 2 digits and of 7 digits 84 combinations of 3 digits and of 6 digits 126 combinations of 4 digits and of 5 digits 255 combinations in all.
Assuming the digits cannot be repeated, there are 7 combinations with 1 digit, 21 combinations with 2 digits, 35 combinations with 3 digits, 35 combinations with 4 digits, 21 combinations with 5 digits, 7 combinations with 6 digits and 1 combinations with 7 digits. That makes a total of 2^7 - 1 = 127: too many for me to list. If digits can be repeated, there are infinitely many combinations.
If the numbers contain zeros, the total number of combinations is 10,000. You can work this out easily logically: For ten single-digit numbers (0,1,2,3,4,5,6,7,8,9) then there are 10 possible 'combinations' For numbers with 2 digits then for each possible digit in the 10s column (e.g. in the 20s range) there are another 10 possible combinations (20,21,22,23,24,25,26,27, 28,29). As there are 10 possible ranges (single digits, teens, twenties, thirties etc) there will be 10 X 10 or 100 possible combinations. using the same logic, for three digits, there will be 10 X 10 X 10 or 1000 digits. And for 4 digits there will be 10 x 10 x 10 x 10 = 10,000 possible combinations. So for a number, say, with x digits, the total number of combinations of those digits will be 10 x 10 x 10..... etc with x numbers of 10s in the calculation. You can find out the number of combinations of any set of letters or numbers in the same way. as an example, to find out, say, the possible combinations of letters in the alphabet of 26 letters, then using the same method this can be given as 26 x 26 x 26 x 26............. with 26 '26's' in a row multiplied together. This gives the staggering amount of approximately 615612 followed by 31 zeros.
Perhapsf you specified the number of digits. e.g. 0-9 with two digits.