Advertisement
Istanvir389

16-8-17

Aug 16th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. divisors
  2. #include<stdio.h>
  3. int main()
  4.  
  5. {
  6. int N,i;
  7. printf("Enter Number ::");
  8. scanf("%d",&N);
  9. printf("1\n");
  10. for(i=2; i<N/2;i++)
  11. {
  12.  
  13. if(N%i==0)
  14. {
  15. printf("\n%d",i); }
  16. }
  17. printf("\n%d",N);
  18. return 0;
  19. }
  20.  
  21.  
  22. divisor of 4 6
  23.  
  24. #include<stdio.h>
  25. int main()
  26. {
  27. int n,i,sum=0;
  28. printf("Enter N ::");
  29. scanf("%d",&n);
  30. for(i=1;i<=n;i++)
  31. {
  32. if(i%8!=0)
  33. {
  34.  
  35. if(i%4==0 && i%6==0)
  36. {
  37. sum=sum+i;
  38. }
  39. }}
  40. printf("Sum is %d",sum);
  41. return 0;}
  42.  
  43.  
  44. odd number
  45. #include<stdio.h>
  46. int main()
  47. {
  48. int i, sum=0;
  49. for(i=1;i<=100;i=i+2)
  50. {
  51. sum=sum+i;
  52. }
  53. printf("The sum of the odd number is %d",sum);
  54. return 0;
  55. }
  56.  
  57.  
  58. EVEN NUMBER
  59. #include<stdio.h>
  60. int main()
  61. {
  62.  
  63.  
  64. int i, sum=0;
  65. for(i=0;i<=100;i=i+2)
  66. {
  67. sum=sum+i;
  68. }
  69. printf("The sum of the even number is %d",sum);
  70. return 0;
  71. }
  72.  
  73.  
  74. factorial
  75.  
  76. #include<stdio.h>
  77. int main()
  78. {
  79. double n,i;
  80. printf("Enter input ::");
  81. scanf("%lf",&n);
  82. double fact=1;
  83. for(i=n;i>=1;i--)
  84. {
  85. fact=fact*i;
  86. }
  87.  
  88.  
  89. printf("The Factorial is %lf",fact);
  90. return 0;
  91. }
  92.  
  93.  
  94. factorial(i--)
  95.  
  96. #include<stdio.h>
  97. int main()
  98. {
  99. double n,i;
  100. printf("Enter input ::");
  101. scanf("%lf",&n);
  102. double fact=1;
  103. for(i=1;i<=n;i++)
  104. {
  105. fact=fact*i;
  106. }
  107.  
  108.  
  109. printf("The Factorial is %lf",fact);
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement