Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 8 part 2 v.06
//gcc 5.4.0 //Problem 2: //Write a C program that replaces each occurrence of a given value in an array by a new value. //(d) Write a pseudocode for this program //(e) Implement your pseudocode in C. (due next lab) //(f) Test You program using the following: //a. The character does not exist in the array. //b. Input sting: “aaaaaaaaaaaaaaaaaaaaa” and the given character is ‘a’. // char C[5]={1,2,3,4,5}; // char x[10]; // char y[10]; // READ x // READ y // // int n=size of array; // for(i=0;i<=n;i++){ // if(C[i]==x){ // C[i]=y; // printf("%c",C[i]); // } // else{ // printf("%c",C[i]); // continue; // } // } #include <stdio.h> int main(void) { char C [5]={1,2,3,4,5}; char x [10]; char y [10]; int z=0; scanf("%s",x); scanf("%s",y); printf("%s\n%s\n%d\n",x,y,C[0]); int n=5; for(int i=0;i<=n;i++){ printf("%d\n",C[i]); if(C[i]==x){ C[i]=y; printf("%c\n",C[i]); } else if(z==(n-1)){ printf("That character isn't in the array"); break; } else{ printf("%c\n",C[i]); ++z; continue; } } }
run
|
edit
|
history
|
help
0
muuchas funciones utiles
Avance 2 de pregunta 5
piesa perdida
p20
finding 3 ones in a row
Fgets and String Stuff
DUE BY TUESDAY
Assignment 8 pt 2
Project 4 v1
B_141202_CONTADORPALABRAS