Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Assignment 8
//gcc 5.4.0 /* Problem 1: Write a C program that searches for a given value in an array of characters. The program should return the index of the value if it exists, otherwise, it should print -1. You can initialize the array in your code by an input string. (a) Write a pseudocode for this program (b) Implement your pseudocode in C. (c) Test You program using the following code: a. Input string: “The George Washington University” and search for the characters: ‘W’, ‘w’, ‘!’, ‘n’, ‘ ‘ Problem 2: Write a C program that replaces each occurrence of a given value in an array by a new value. (a) Write a pseudocode for this program (b) Implement your pseudocode in C. (due next lab) (c) 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’. */ /* #include <stdio.h> int main(void) { int n; char name[30]="The George Wasington University"; n=sizeof(name); for(int i=0; i<n; i++){ if (name[i]=='W'){ printf("W detected\n"); } else if (name[i]=='w'){ printf("w detected\n"); } else if (name[i]=='!'){ printf("! detected\n"); } else if (name[i]=='n'){ printf("n detected\n"); } else if (name[i]==' '){ printf("' ' detected\n"); } else{ printf("No elements being detected %-1\n"); } } return 0; } */ #include <stdio.h> int main (void){ char array1[4]={'w','x','y','z'}; int n; for(int i=0; i<4; i++){ scanf("%c", &array1[i]); } for(int j=0; j<4; j++){ printf("%c", array1[j]); } n=sizeof(array1); printf("%d", n); return 0; }
run
|
edit
|
history
|
help
0
gets.c
binary to txt
Prime no
My first array
C_141210_Funciones
Area
18BCE2182 ASSESS_1 Q2-3
AVANCE PREGUNTA 3 FICHEROS
Goodone for understanding array passing
b=1,c=1