Quote:
I'm beginner in C programming , i just want to know why do we code programmes that detect odd or even numbers and what is the use of that
The primary reason of the toy problems you are solving, is to have you practice on programming and analyze.
The practical usage of a given problem is secondary.
Learn to indent properly your code, it show its structure and it helps reading and understanding.
#include<stdio.h>
#include<stdlib.h>
main()
{
int N,i,sum,odd,even;
system("color a ");
printf("give a number : ");
scanf("%d",&N);
sum=0;
even=0;
odd=0;
for(i=0;i<=N;i++)
{
if(i%3!=0&&i%4!=0)
{
sum=sum+i;
if(i%2==0)
even+=i;
else
odd+=i;
}
}
printf("sum odd = %d \n sum even = %d \n sum all = %d",odd,even,sum);
return 0;
}
Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]