Computer Science, asked by kramish528, 8 months ago

WAP to input a number and print the sum of all odd digits of that number direct method or input​

Answers

Answered by riyaamen303
1

Answer:

#include <stdio.h>

#include<conio.h>

void main()

{

   int i, num, odd_sum = 0;

 

   printf("Enter the value of num\n");

   scanf("%d", &num);

   for (i = 1; i <= num; i++)

   {

       if (i % 2 == 0)

           i++;

       else

           odd_sum = odd_sum + i;

           i++;

   }

   printf("Sum of all odd numbers  = %d\n", odd_sum);

   getch();

}

Hope this helps you.Please add Brainliest if it is correct.

Similar questions