Answer to Question #277262 in C for Clint

Question #277262

#include <stdio.h>


int main()

{

 int x[9];

 int res;

 

  printf("Input 9 integers:\");

 scanf("%d %d %d %d %d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4],&x[5],&x[6],&x[7],&x[8]);

  

 printf("\%d\%d\%d = %d\",x[0],x[1],x[2], x[0]+x[1]+x[2]);

 printf("%d\%d\%d = %d\",x[3],x[4],x[5], x[3]+x[4]+x[5]);

 printf("%d\%d\%d = %d\",x[6],x[7],x[8], x[6]+x[7]+x[8]);

 printf("-------------------------\");

 res = x[0]+x[3]+x[6]+x[1]+x[4]+x[7]+x[2]+x[5]+x[8];

 printf("%d\%d\%d = %d",x[0]+x[3]+x[6],x[1]+x[4]+x[7],x[2]+x[5]+x[8],res);

  

 return 0;

}


1
Expert's answer
2021-12-08T08:15:55-0500
#include <stdio.h>

int main()
{
    int x[9];
    int res;
 
    printf("Input 9 integers:\n");

    scanf("%d %d %d %d %d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4],&x[5],&x[6],&x[7],&x[8]);
  
    printf("%d + %d + %d = %d\n",x[0],x[1],x[2], x[0]+x[1]+x[2]);
    printf("%d + %d + %d = %d\n",x[3],x[4],x[5], x[3]+x[4]+x[5]);
    printf("%d + %d + %d = %d\n",x[6],x[7],x[8], x[6]+x[7]+x[8]);
    printf("-------------------------\n");

    res = x[0]+x[3]+x[6]+x[1]+x[4]+x[7]+x[2]+x[5]+x[8];

    printf("%d + %d + %d = %d",x[0]+x[3]+x[6],x[1]+x[4]+x[7],x[2]+x[5]+x[8],res);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS