Question
convert this code from C to C++
include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlo
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <locale>

using namespace std;

void filtre(double x[], double y[], double yo[], int m, int N);
int Nm=10000;

int main()
{
setlocale(LC_ALL,"");
double x[Nm],y[Nm],yo[Nm]={0.0};
int m;
FILE *dosya1=fopen("D:\veri\678.txt","r");
FILE *dosya2=fopen("D:\veri\data2.txt","w+");
int i=0;
while(!feof(dosya1))
{
fscanf(dosya1,"%lf %lf",&x[i],&y[i]);
i++;
}
fclose(dosya1);
int N=i;
cout << "Pencere Genisligi m=";
cin >>m;
filtre(x,y,yo,m,N);
for(int k=0;k<N;k++)
fprintf(dosya2,"%0.40f %0.41f %0.41f\n",x[k],y[k],yo[k]);
fclose(dosya2);
}
void filtre(double x[], double y[], double yo[], int m, int N)
{
int m2=(m-1)/2;
for(int i=0;i<N;i++)
{
int mL=i-m2;
if(mL<1)mL=1;
int mU=i+m2;
if(mU>N)mU=N;
double T=0.0;
for(int j=mL;j<=mU;j++)
T=T+y[j];
yo[i]=T/m;
}

}

i do not have 673.txt so can not execute the program let me know if any doubt is there , thanks

Add a comment
Know the answer?
Add Answer to:
convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double...

    Convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlocale (LC ALL,") double x(Nm) , y [ Nm],yo Nml®(0.0); int m; FILE dosyal-fopen("D:/veri/673.txtr FILE dosya2-fopen("D:/veri/data2.txt int i-0 while( feof (dosyal)) fscanf (dosyal, " ",xi sytil) fclose (dosyal) int Nij printf("Pencere Genişligi scanf() 3 filtre(x,y.Yo,m,N) for(int k-0keNkt+)fprintf (dosya2, 10.41 10.411 0.41fn",x[k],y[k].yo[k]) fclose(dosya2) void filtre (double x double y. double yoll, int m, int...

  • From the following code, define a new structure and use it to define the upper and...

    From the following code, define a new structure and use it to define the upper and lower limits of the trapezoidal and simpsons functions. #include<stdio.h> #include "math.h" #include <stdlib.h> double F1(double x) { return 1000 * exp(7*x) * cos(0.3*M_PI*x); } double F2(double x) { return pow(x,3) - (0.23*x) + 30.67; } void calculateIntegeralBySimpson(int n) { FILE *fp = fopen("data_Simpson_method.txt", "w");    int i; /* Calculating for first half of the interval */ double lowerLimit = -5, upperLimit = 0, x[n+1],...

  • please help, no explanation just need answer #include <stdio.h> #include <stdlib.h> int main(void) { int -x5);...

    please help, no explanation just need answer #include <stdio.h> #include <stdlib.h> int main(void) { int -x5); for (int = 0; i < 5; i++) { x[i] = malloc(sizeof (int) - 5); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { x[i][j] = i j ; modify(x, 5, 5); return 0; Which of the implementations of method modify below set all elements of the matrix x to zero? 1. void...

  • Code that needs to be modified: #include <stdio.h> #include <math.h> int main(void) { FILE * fileout; int ix,iy,it,Nt; double newV[31][21],V[31][21],x,dx,y,dy; fileout=fopen("buckbeak....

    Code that needs to be modified: #include <stdio.h> #include <math.h> int main(void) { FILE * fileout; int ix,iy,it,Nt; double newV[31][21],V[31][21],x,dx,y,dy; fileout=fopen("buckbeak.dat","w"); printf("\nEnter number of iterations "); scanf("%d",&Nt); dx=0.10; dy=0.10;    for(iy=0; iy<21; iy=iy+1) { for(ix=0; ix<31; ix=ix+1) { V[ix][iy]=0.0; } } iy=20; for (ix=0;ix<31; ix=ix+1)    {    V[ix][iy]=8.0;    } for (it=0; it<Nt;it=it+1) { for(iy=1; iy<20;iy=iy+1) { for(ix=1;ix<30; ix=ix+1) { newV[ix][iy]=0.25*(V[ix+1][iy]+V[ix-1][iy]+V[ix][iy+1]+V[ix][iy-1]); } } for (iy=1; iy<20; iy=iy+1) { for(ix=1; ix<30; ix=ix+1) { V[ix][iy]=newV[ix][iy]; } }    } for (iy=0;iy<21;iy=iy+1) { y=dy*iy; for (ix=0;ix<31;ix=ix+1) {...

  • C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main functi...

    C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main function int main() {    //seeding a random number    srand(time(0));    //define the arrays for the wagered, winning amount, percent amount    double amounts[7] = { 1, 5, 10, 20, 50, 100, 1000 };    double payoff[7] = { 100, 500, 1000, 2000, 5000, 10000, 100000 };    double percent[7] = { 0.01, 0.05, 1, 2,...

  • Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int...

    Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...

  • #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void...

    #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include<time.h> void insertionSort(int arr[], int n); void merge(int a[], int l1, int h1, int h2); void mergeSort(int a[], int l, int h) { int i, len=(h-l+1); //Using insertion sort for small sized array if (len<=5) { insertionSort(a+l, len); return; } pid_t lpid,rpid; lpid = fork(); if(lpid<0) { //Lchild proc not created perror("Left Child Proc. not created\n"); _exit(-1); } else if (lpid==0) { mergeSort(a,l,l+len/2-1); _exit(0); } else...

  • C Programming // Compile with: clang radio.c -o radio // Run with: ./radio #include <stdio.h> #include...

    C Programming // Compile with: clang radio.c -o radio // Run with: ./radio #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> // @Name    loadMusicFile // @Brief   Load the music database //          'size' is the size of the database. char** loadMusicFile(const char* fileName, int size){ FILE *myFile = fopen(fileName,"r"); // Allocate memory for each character-string pointer char** database = malloc(sizeof(char*)*size); unsigned int song=0; for(song =0; song < size; song++){       // Allocate memory for each individual character string       database[song] =...

  • I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){...

    I need the pseudocode for this c program source code. #include<stdio.h> void printarray(int array[], int asize){ int i; for(i = 0; i < asize;i++) printf("%d", array[i]); printf("\n"); } int sum(int array[], int asize){ int result = 0; int i = 0; for(i=0;i < asize;i++){ result = result + array[i]; } return result; } int swap( int* pA,int*pB){ int result = 0; if(*pA > pB){ int tamp = *pA; *pA = *pB; *pB = tamp; result = 1; } return result;...

  • Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[],...

    Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[], int *p_top, char value); char pop(char S[], int *p_top); void printCurrentStack(char S[], int *p_top); int validation(char infix[], char S[], int *p_top); char *infix2postfix(char infix[], char postfix[], char S[], int *p_top); int precedence(char symbol); int main() { // int choice; int top1=0; //top for S1 stack int top2=0; //top for S2 stack int *p_top1=&top1; int *p_top2=&top2; char infix[]="(2+3)*(4-3)"; //Stores infix string int n=strlen(infix); //length of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT