write a program to input a two digit integer and using switch case print the number name of the last digit of the integer
input 46 output six/six
Answers
Answered by
0
Answer:
#include<stdio.h>
int main(){
int num, onesDigit;
printf("Enter a number : ");
scanf("%d",&num);
// ones digit of number is stored in the variable
onesDigit = num%10;
switch(onesDigit){
case 0: printf("zero");break;
case 1: printf("one");break;
case 2: printf("two");break;
case 3: printf("three");break;
case 4: printf("four");break;
case 5: printf("five");break;
case 6: printf("six");break;
case 7: printf("seven");break;
case 8: printf("eight");break;
case 9: printf("nine");break;
default: printf("An error occurred");
}
return 0;
}
Attachments:
Similar questions