Batch 5 IEEE
Batch 5 IEEE
if(n>0)
Batch number – 5
go to step 3
V.Bhavya-241FA04950
5. for (i=0; I < digit ;i++)
Sd.Bashu-241FA04949 6. print(digit)
V. SyamPrasad-241FA04939 7. stop
T.Deekshith-241FA04980
Question-7.B
Question-7.A 1. Ascending Order is arranging of numbers
“Printf statement is used to print desired from smallest value to largest value. Develop a
numbers or characters in C”. Develop an program to read an integer number with
algorithm that can read a number as input from minimum of 6 digits as input rearrange the
the keyboard and print a number with the digits of the number in ascending order.
repetition every digit, the digit number of times. Examples:
Examples: INPUT: 465128
INPUT: 12 OUTPUT: 124568
INPUT: 46 INPUT: 9447523657812 OUTPUT:
OUTPUT: 122 1223445567789
OUTPUT: 4444666666 Logic
} Algorithm
} 1. Start
n=n/10 temp /= 10
6. if(temp>0)
go to step5 printf("\n");
7 .if (digit == i) }
8. print(digit)
Program
if (digit == i) { Logic
} temp = num
} digit = temp % 10
} if (digit == i) {
print(digit) digit = temp % 10;
Algorithm if (digit == i) {
2.read num }
5.digit = temp % 10 }
temp/=10 }
go to step5 return 0;
6 .if (digit == i) }
7. print(digit)
8 .stop
Program
#include <stdio.h>
int main() {
Logic go to step6
switch(digit) { 7. if(num == 0)
num /= 10;
if (num == 0) {
printDigitInWords(0);
printf("\n");
Algorithm
1. Start
2. read digit
3. switch (digit)
Program
4. Enter cases
#include <stdio.h>
5. reversed = reversed * 10 + num % 10
int printDigitInWords(int digit) {
switch (digit) { }
int reversed = 0;
num /= 10;
}
Question-7.C
return reversed;
ii. For the input taken in Question 1. C (i), the
} number can also be written based on their place
in the digits value. Develop a program to
int main() {
rewrite the number in words based on their
int num, temp; place value.
if (num == 0) { Logic
printDigitInWords(0); if (num == 1)
printf("\n"); printf("ONE")
printf("THREE") printf("SEVENTEEN")
printf("FOUR") printf("EIGHTEEN")
printf("SIX") 1.start
printf("SEVEN") 3. if(num == 1)
else if (num == 9)
printf("NINE") (TWO)
print_single_digit(num)
if (num == 10)
print("TEN")
print("ELEVEN");
print("TWELVE")
print("THIRTEEN")
print("FOURTEEN")
print("FIFTEEN")
print("SIXTEEN")
print("SEVENTEEN")
print("EIGHTEEN")
5. else if(ones != 0)
print_single_digit(ones)
6. else (num == 0)
print(ZERO)
7.stop
if (num < 10) {
print_single_digit(num);
}
if (num == 10)
Program printf("TEN");
printf("ONE"); printf("TWELVE");
printf("TWO"); printf("THIRTEEN");
printf("THREE"); printf("FOURTEEN");
printf("FOUR"); printf("FIFTEEN");
printf("FIVE"); printf("SIXTEEN");
printf("SIX"); printf("SEVENTEEN");
printf("SEVEN"); printf("EIGHTEEN");
printf("EIGHT"); printf("NINETEEN");
} if (tens == 2) printf("TWENTY");
else if (tens == 7) }
printf("SEVENTY");
int main() {
else if (tens == 8) printf("EIGHTY");
int number;
else if (tens == 9) printf("NINETY");
printf("Enter a number: ");
int ones = num % 10;
scanf("%d", &number);
if (ones != 0) {
print_number_in_words(number);
printf(" ");
}
print_single_digit(ones);
}
}
}
if (num == 0) {
printf("ZERO\n");
return;
}
print_single_digit(hundreds);
printf(" HUNDRED");
num %= 100;
if (num != 0) {
printf(" ");
}
}
if (num > 0) {
THANK YOU