Jump to content

Archive:Sum and reverse of entered two numbers: Difference between revisions

From IdeaWazaWiki
wikademia>Mickraus
The code is now Standard C
wikademia>Wikademia
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<source lang="c">//Sum and reverse of entered two nos
<source lang="c">/* display sum of 2 digits, and the digits transposed */
#include <stdio.h>
#include <stdio.h>



Latest revision as of 16:06, 12 June 2009

<source lang="c">/* display sum of 2 digits, and the digits transposed */

  1. include <stdio.h>

int main(void) {

 short rev, sum, dig1, dig2;
 printf("Enter 2 digits separated by a space: ");
 fflush(stdout);
 scanf("%hd%hd", &dig1, &dig2);
 sum = dig1 + dig2;
 rev = dig2 * 10 + dig1;
 printf("sum = %hd\nrev = %hd\n", sum, rev);
 /* indicate success */
 return 0;

}</source>