#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,m;
clrscr();
for(i=0;i<4;i++)
{
for(j=i+1;j<=4;j++)
{
printf("%d",j);
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
printf("\n");
for(k=i;k>=1;k--)
{
printf("%d",k);
}
for(j=4;j>=i+1;j--)
{
printf("%d",j);
}
getch();
}
To write a program that inputs a number and displays the digits absent in it, you can follow these steps: Convert the input number into a set of its digits. Create a set of all possible digits (0-9). Subtract the set of digits from the complete set to find the missing ones. Display the missing digits. Here’s a simple example in Python: number = input("Enter a number: ") present_digits = set(number) all_digits = set('0123456789') missing_digits = all_digits - present_digits print("Missing digits:", ''.join(missing_digits))
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.
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
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()); }
no thanks
To write a program that inputs a number and displays the digits absent in it, you can follow these steps: Convert the input number into a set of its digits. Create a set of all possible digits (0-9). Subtract the set of digits from the complete set to find the missing ones. Display the missing digits. Here’s a simple example in Python: number = input("Enter a number: ") present_digits = set(number) all_digits = set('0123456789') missing_digits = all_digits - present_digits print("Missing digits:", ''.join(missing_digits))
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.
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
In decimal we write a number by using a combination of 10 digits (0-9). In base 2, however, numbers are written by using a combination of only 2 digits (0 & 1). We call this number system binary.
#include <stdio.h> int main(int argc, char **argv) { if (argc<1) { printf("Usage: %s number\n",argv[0]); return -1; } int digits=1, i=atoi(argv[1]); while (i/=10) ++digits; printf("%d\n",digits); }
To write the number in digits, you would write it like this: 95,032,659,004.
8,400,000.00
99
Not completely to its end. If you can completely write a number with digits, then it's a rational number.
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
Write the digits in such a way that there are six digits to the right of the number of millions, and three digits to the right of the thousands. Fill out missing digits with zeros.