Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <stdio.h>
  4.  
  5. void main()
  6. {
  7.     int thousand = 1000;
  8.     int hundred = 100;
  9.     int ten = 10;
  10.  
  11.     char a, b, c, d;
  12.     printf("Enter number for thousands: ");
  13.     scanf("%c", &a);
  14.  
  15.     printf("Enter number for hundreds: ");
  16.     rewind(stdin);
  17.     scanf("%c", &b);
  18.  
  19.  
  20.     printf("Enter number for tens: ");
  21.     rewind(stdin);
  22.     scanf("%c", &c);
  23.  
  24.  
  25.     printf("Enter number for units: ");
  26.     rewind(stdin);
  27.     scanf("%c", &d);
  28.     rewind(stdin);
  29.     int newNumber = (int)(a-48) * thousand + (int)(b-48) * hundred + (int)(c-48) * ten + (int)(d-48);
  30.     printf("%d", newNumber);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement