diff --git a/sumofoddnaturalno b/sumofoddnaturalno new file mode 100644 index 00000000..114b16c1 --- /dev/null +++ b/sumofoddnaturalno @@ -0,0 +1,15 @@ +#include +void main() +{ + int i,n,sum=0; + + printf("Input number of terms : "); + scanf("%d",&n); + printf("\nThe odd numbers are :"); + for(i=1;i<=n;i++) + { + printf("%d ",2*i-1); + sum+=2*i-1; + } + printf("\nThe Sum of odd Natural Number upto %d terms : %d \n",n,sum); +}