Adition all Odd & Even number from User Input

 Odd Number

#include
main()
{
    int i,n,a=0;    scanf("%d",&n);
    for(i=1;i<=n;i=i+2)
    a=a+i;
    printf("%d\n",a);
}








Even Number

#include
main()
{
    int i,n,a=0;
    scanf("%d",&n);
    for(i=0;i<=n;i=i+2)
    a=a+i;
    printf("%d\n",a);
}


Facebook


Comments

Popular posts from this blog

For loop C++

VALENTINE DAY PROGRAME

Charecter & space founder in c program