Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 8 part 2 v.05
//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; char y; scanf("%c",&x); scanf("%c",&y); printf("%d\n%d\n%d\n",x,y,C[0]); int n=5; for(int i=0;i<n;i++){ //printf("%d",C[i]); if(C[i]==x){ C[i]=y; printf("%c\n",C[i]); } else{ printf("%c\n",C[i]); continue; } } }
run
|
edit
|
history
|
help
0
string_ptr_to_fct_param_v2
6 ejercicio trabajo semanal 4
square pyramid
TeleBook2
18BCE2182 LAB FAT-2-A-i
recursive fundamentos
C(gcc) Local Time and math.h Example
18BCE2182 ASSESS_1 Q2-2
DUE TUESDAY
E