Hello
I am trying to write a program that decrypts a string that the user enters with the caesar cypher.
I am pretty sure the rest of my program is correct but I am getting this error: error: Expected '(' before 'else' for line 37 (if else (plain [i] > 96 && plain[i] < 123)
here is the program:
Code:
/* The program encrypts a string with the caesar cypher*/
#include<cs50.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
int
main(int argc, char *argv[])
{
// check if the argument entered is a digit
if (!isdigit(*argv[1]) || argc !=2)
{
printf("Please enter one number as the argument to use to encrypt\m")
return 1;
}
// convert the argument to an int
int k = atoi(argv[1]);
// get the user's plaintext to encrypt
printf("\nplaintext: ");
char *plain = GetString();
// encrypt
printf("\cyphertext: ");
for (int i = 0, n = strlen(plain); i < n; i++)
{
// if the letter is lowercase
if(plain[i] > 64 && plain[i] < 91)
{
int ascii = plain[i];
int p = (ascii - 65);
int c = (p + k) % 26;
int cypher_p = (c + 65);
printf("%c", cypher_p);
}
// if the letter is uppercase
// this is where the error is
if else(plain[i] > 96 && plain[i] < 123)
{
int ascii = plain[i];
int p = (ascii - 97);
int c = (p + k) % 26;
int cypher_p = (c + 97);
printf("%c", cypher_p);
}
// if the element in plain is a space print a space
if else(plain [i] == " ")
{
printf(" ");
}
}
printf("\n");
}
Why do I keep getting that error?
I literally just started programming like two weeks ago so please explain the fix (unless it is just something really stupid that I'm missing haha).