Thursday, February 17, 2011

program for display prod of all odd number from 1 to n

#include<stdio.h>
#include<conio.h>
void main()
 {
 clrscr();
 int i,n,tot=1;
 printf("Enter any limit :-");
 scanf("%d",&n);
 for(i=1;i<=n;i++)
  {
  if(i%2 != 0)
   {
   tot=tot*i;
   }
  }
 printf("Product is %d",tot);
 getch();
 }

No comments: