- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › Code to convert to cipher text only when alphabetical characters
Tagged: arrays, Caesar project, isalpha
[dm_code_snippet background=”yes” background-mobile=”no” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
#include<stdio.h> #include<cs50.h> #include<string.h> #include<ctype.h> int main(void) { string name = get_string("Enter: "); printf("Entered text by user: %s\n", name); int n = strlen(name); printf("lenght of entered text: %i\n", n); int key = get_int("enter key: "); for (int i = 0; i < n; i++) { { isalpha name[i] = name[i] + key; } } printf("cipher text: %s\n", name); }
[/dm_code_snippet]
Intend to convert to cipher text only when alphabetical characters. Facing problem coding if name[i] is alphabetical, only then name[i] = name[i] + key.
Reply
https://edstem.org/us/courses/176/discussion/1002204[learn_press_profile]