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
#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);
}
Comments
Post a Comment