-2

this code Works

#include <cs50.h>
#include <stdio.h>
#include <string.h>

int main(void)

{
int k;
 printf("write as trin\n");
 string s= GetString();
 for (int i=0; i<strlen(s);++i)
 {  
  if(s[i]+13>122 || s[i]+13>90)
  k=s[i]-109;
  {
  printf("%c\n",'a'+(k-1));
  }

 }}

when i add the else no..

#include <cs50.h>
#include <stdio.h>
#include <string.h>

int main(void)

{
int k;
 printf("write as trin\n");
 string s= GetString();
 for (int i=0; i<strlen(s);++i)
 {  
  if(s[i]+13>122 || s[i]+13>90);
  k=s[i]-109;
  {
  printf("%c\n",'a'+(k-1));
  }
  else 
  {
  printf("%c",s[i]+13);
  }

 }}
1
  • it's unclear what you're asking. you should provide more details!
    – kzidane
    Commented Jun 30, 2015 at 18:24

1 Answer 1

0

You've got a semicolon at the end of the if in your second example. That ends the statement. You need to remove that. You should also put your curly braces around the entire if statement:

  if(s[i]+13>122 || s[i]+13>90)
  {
      k=s[i]-109;
      printf("%c\n",'a'+(k-1));
  }
  else 
  {
      printf("%c",s[i]+13);
  }

Not the answer you're looking for? Browse other questions tagged .