Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Assignment 8
//gcc 5.4.0 /* 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’, ‘ ‘ */ #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; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
C_141120_factorial01
Atoi without minus
variable number of arguments 3
c
Prime no
Run code before/after main in C (GCC)
Practice flipping the stars
Char data type.c
B_141107_Factorial
150114_MatrizSumaPerimetro
Please log in to post a comment.