Empowering CS learners, aspiring programmers, and startups with AI, Data Science & Programming insights — scaling skills from learning foundations to enterprise-grade solutions.
Code to convert to cipher text only when alphabetical characters
#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.