Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int Wn(int n)
- {
- int value;
- if(n%2==0) //for even
- {
- value = (0.5*n + pow(n,2));
- }
- else
- {
- value=(n-5)*n; //for odd
- }
- return value;
- }
- int main(int argc, char *argv[]) {
- int n;
- int a;
- int b;
- int c=0;
- float results[100];
- printf("a=");
- scanf("%f",&a);
- printf("b=");
- scanf("%f", &b);
- for(n=a; n<=b; n++)
- {
- results[c]= Wn(n);
- c++;
- }
- for(n=0; n<c; n++, a++)
- {
- printf("\t\t\t\t\t\tV(%d) = %.2f\n", a, results[n]);
- }
- //float value(n);
- printf("results");
- return 0;
- }
Add Comment
Please, Sign In to add comment