WAP to input a number and print the sum of all odd digits of that number direct method or input
Answers
Answered by
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
Math,
4 months ago
Math,
4 months ago
Math,
8 months ago
World Languages,
1 year ago
English,
1 year ago