Header Ads Widget

Ticker

6/recent/ticker-posts

FIND THE SUM OF ODD NUMBERS FROM 0 TO N

 COMPUTER GAYN


Q.FIND THE SUM OF ODD NUMBERS FROM 2 TO N?

ANS:-               

 #include<stdio.h>
int main()
{
  int i, number, Sum = 0;
 
  printf("\n Please Enter the Maximum Limit Value : ");
  scanf("%d", &number);
  
  printf("\n Odd Numbers between 0 and %d are : ", number);
  for(i = 1; i <= number; i++)
  {
  	if ( i%2 != 0 ) 
  	{
  		printf("%d  ", i);
        Sum = Sum + i;
  	}
  }
  printf("\n \n The Sum of Odd Numbers from 1 to %d  = %d", number, Sum);

  return 0;
}


                click on the link👇👇👇👇👇👇


TP-Link TL-WR841N 300Mbps Wireless N Cable, 4 Fast LAN Ports, Easy Setup, WPS Button, Supports Parent Control, Guest Wi-Fi Router   

Post a Comment

0 Comments