arrays - How do I multiply a long integer with different numbers in C program? -


i new c programming , writing program takes number suppose 9 digits long. after multiply each digit either 1 or 2. using arrays ask user enter numbers. know if there way multiply 9 numbers different numbers 1 integer instead of using arrays? here code arrays:

#include <stdio.h>  int main(void) {      int sin_num[9];     int num1;     int num2, num11, num12;     int num3, num4, num5, num6, num7, num8, num9, num10;        for(num1=0; num1<9; num1++) {             printf("enter sin number 1 one:");             scanf("%d", &sin_num[num1]);     }       num2 = sin_num[0] * 1;     num3 = sin_num[1] * 2;     num4 = sin_num[2] * 1;     num5 = sin_num[3] * 2;     num6 = sin_num[4] * 1;     num7 = sin_num[5] * 2;     num8 = sin_num[6] * 1;     num9 = sin_num[7] * 2;     num10 = sin_num[8] * 1; 

right doing this: element 1 * 1 element 2 * 2 element 3 * 1 how can do, lets if enter 123456789 multiply different numbers:

123456789 121212121 

well couldn't understand asking. anyways hope looking for.....

 #include<stdio.h>    int main()  {     long int nine_digit_num;    int step=100000000;    int digit,input_num,i;     printf("enter 9 digit number:\n");    scanf("%ld",&nine_digit_num);      for(i=1;i<=9;i++)    {        printf("enter number multiply %d digit:\n",i);      scanf("%d",&input_num);      digit=nine_digit_num/step; // , next step used      digit=digit%10;            // obtain individual digits.      printf("%d*%d=%d\n",digit,input_num,digit*input_num);      step=step/10;   }    return 0;  } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -