Problems With Your Code
Code That Does Nothing
while (x = 0);
The above line sets x to be 0, then checks if the condition of while is true. Since x is 0, the logical expression evaluates to false (anything that's not 0 evaluates to true). So the body of the while will never be executed, which is by the way nothing, an empty statement, a semicolon.
You should just remove this line.
Signalling Error, But Not Terminating
printf("Invalid Input!\n");
This tells the user that the input is wrong, but at this point there's no point continuing the function, you should as well exit:
return -1;
0 means all OK to the Linux shell, non-zero usually means an error, for this return something non-zero when your program terminates with n error.
Unnecessary Scopes (Braces)
There's an opening brace just before the marked lines below.
{
while (firstnum <= secondnum)
// ...
{
printf("List of all Odd Numbers : ");
While it makes sense sometimes to create a new scope, I don't see why you'd need on there.
Incorrect Indentations
Please, indent your code correctly to make it more human-readable.
Misleading Output
printf("\nSum of square all odd numbers : %d", sOdd);
So the user would expect (I would expect XD) the summary of the squares of all the odd numbers (in a given range). E.g. 12 + 32 + 52 + 72 = 1 + 9 + 25 + 49 = 84. However, what you calculate is something different:
sOdd = sOdd + ((firstnum * secondnum) - sum);
I'd fix either the formula (sOdd += firstnum * firstnum;) or fix the output message to tell what is actually printed.
Overwriting Important Values
In your code you change the value of firstnum in your first while loop, so you won't be able to know what was the lower value of your original range. You should keep this value and use it later when you want to list the numbers and not start from 10.
Everything Fixed
So all the above fixed would create a code like this:
#include <stdio.h>
int main()
{
int firstnum = 0;
printf("Input firstnum value : ");
scanf("%d", &firstnum);
int secondnum = firstnum - 1; // ensuring that the sanity check below would fail if the user does not enter a valid number
printf("Input secondnum value : ");
scanf("%d", &secondnum);
//
// Sanity check
//
if (firstnum > secondnum)
{
printf("Invalid Input!\n");
return -1;
}
//
// Calculate and print the results
//
int sum = 0;
int even = 0;
int sOdd = 0;
for (int i = firstnum; i <= secondnum; i++)
{
sum += i;
if (i % 2 == 0)
{
even += i;
}
else
{
sOdd += i * i;
}
}
printf("Sum of all numbers : %d\n", sum);
printf("List of all Odd Numbers : ");
for (int i = firstnum % 2 == 1 ? firstnum : firstnum + 1; i <= secondnum; i += 2) // The iteration starts from firstnum, if it is odd, or from firstnum + 1, if it is even
printf("%d ", i);
printf("\nSum of all even numbers : %d\n", even);
printf("Sum of square all odd numbers : %d\n", sOdd);
return 0;
}