Responsive Ads Here

Tuesday, November 25, 2014

1+3+5+......UP TO 9

1+3+5+......UP TO 9

//1+3+5+......UP TO 9
 
 
#include<stdio.h>
main()
{
    int n,a=1,d=2,sum=0,term;
 
    printf("ENTER N=");
    scanf("%d",&n);
 
    term=a+(n-1)*d;
 
    for(a=1;a<=term;a=a+2)
    {
        sum=sum+a;
    }
    printf("ANS=%d",sum);
}

No comments:

Post a Comment

php4

<?php    // Start the session  session_start();  ?>  <!DOCTYPE html>  <html>  <head>       <link rel=&q...