3 like 0 dislike
7.4k views

You have received an encrypted message from Julius Caesar-- the message is ebiil.  You are asked to decipher the message in order to understand what Caesar trying to say to you.

Hint

Luckily, Caesar has given you a hint, he says: 'I, myself, encoded the message by shifting every word backwards by 3.' 

Solution

Write a program that receives 5 characters 'ebiil'. Then decode those characters into 5 new characters.

Example

#include <stdio.h>

int main(int argc, char *argv[]) {


	char a;
    	char b;
	 	
	scanf("%c%c", &a, &b);
	
	//decode the message how??
	
	printf("%c%c", a,b);
	
	return 0;
}

Input

ebiil

 

 

 

 

 

 

 

 

 

 

Output

hello

** REMEMBER ** 
This is an online-compiler, don't put anything except the codes. If you want to make a comment, please use // or /* */

[Exercise] Coding (C) - asked in Chapter 2: Syntax structure of the C language by (5.9k points)
ID: 26955 - Available when: Unlimited - Due to: Unlimited

edited by | 7.4k views

22 Answers

0 like 0 dislike
Hidden content!
* * * ** *** *

int ** * argc, char ** * {
** * ** * ** ** */

* * * int number;
* ** ** *** char a;
*** ** ** * * ** *** b;
* ** ** ** * * c;
* * ** * * * * **** * * d;
* * * ** ** * ** ****** e;
* *** * ** * * **
***** * ** * ** *** forgert how to shift word * * * *** *
* * ** *** * ** ******* * * * * * ** *** * ** * ** ** * * ** **
* *** * * *
* **** * ** ** the message how??
* ** * *
** * **** * ** ** * * * * * * **** **
* ** * *
*** * * return 0;
}
100/100 answered by (449 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
* ** ** * ** ***

* * * * *** ** * {

* * * *
= * *
*** ***
= *** **
= * *
* = ** * *

* = **
** = *
* = *
= *

** * **
*** ***
* *
* *
****

* * ** * ** **
**
100/100 answered by (153 points)
0 0
Case 0: Correct output
Case 1: Wrong output
1 like 0 dislike
Hidden content!
#include * * **
#include * ***** * * * *

/* run this program using the console pauser or add your own getch, **** * ********* **** or input loop */

int main(int argc, char *argv[]) {
* * * * *** **** ** ** a;
* * ** * * * * ** * b;
** * * **** * ** * c;
** * * *** * *** ** * ** d;
** ** * * ** * ** e;
** * * ** ** **
** **** **** * * ** *** ** ****** the words you want to * ***
* *** ** *** *** * **
* * ** ****** * **** = getchar();
* * ** * ***** * = a+3;
**** *** ** * ** * **** * * *
** * * ** ***** * ** * = getchar();
* * * *** * * ** * * *** = b+3;
**** * *** * * ***** **
***** ** * **** ** * * = getchar();
* **** ** * ** ** * = c+3;
* * **** *** ***** ** ** * *
* **** * ** * ** * * * * = getchar();
** ** * * * ***** ** = d+3;
***** ** * * * ** *** *
* *** ** * = getchar();
* ** ** *** * ** ** * *** *** = e+3;
* ***** * * * * *** * * * *** ** *
*** ** ** * * * ** * ** * * * * * ** * * *****
* ** * ** * * ** * * * ** * * * * * * *** &a, &b, &c, &d, ** *****
* * * * *** ***
* * * * * ** ** ** * ** the message how??
** * * * * ***** * *
* * * ** * * ** * ** * ** * *** *** a, b, c, d, e);
* * **** * ****
* * * **** * ** * *** 0;
}
100/100 answered by (281 points)
edited by
0 0
Your program receives only 2 characters, and it doesn't move characters' positions.

Try to make it receive 5 characters, and move their positions forward by 3.
0 0
This exercise expects only 'hello'. However, your code has.....

printf("Put the words you want to decode:");

Kindly consider delete this part :)
1 like 0 dislike
Hidden content!
* * *** * **
* * * * * * *** *

int * *** char ** {
/*
** ** *** */

* * ****** *

** **** ** * *** * ****** ** * *** ** ** * ** * *
a = a+3;
b = *
c =
d = d+3;
e = **

* * * the **
* * ** * * ***
* ******* ** ******* *** *** **

** * ** * ** ** **
** * * ** * * * * * 0;
}
100/100 answered by (273 points)
edited by
0 0
prog.c:28:1: error: unknown type name 'INPUT'
 INPUT
 ^~~~~
prog.c:32:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OUTPUT'
 OUTPUT
 ^~~~~~
prog.c:32:1: error: unknown type name 'OUTPUT'
0 0
Your program can end at
  
    return 0;
}
------------------------------------------
You don't need to put

INPUT

ebiil

OUTPUT

hello
0 0
Case 0: Correct output
Case 1: Wrong output
1 like 0 dislike
Hidden content!
** *** * * * * * *
** ** *** **

/* run this * * the **** * *** or add your own * ***** ***** ** * * or * ** */

int * ** *** * char * * {
* * * * * int num, *
* ** * ** **** * *
*** ** * **
*** * * ****** * *
*** ** ****** for **** = * ** * * *
{
* *** * * * * = * * *** *
** * ** * if * * * * *
* ** * * * = *** ***
* ** * *
}
* * ** * * ** * * * * * * ** ** * *
*** * * ** * * * 0;
50/100 answered by (252 points)
0 0
prog.c: In function 'main':
prog.c:19:2: error: expected declaration or statement at end of input
  return 0;
  ^~~~~~
0 0
Great job using an array and a loop. There are two mistakes found in your code. Please check
1.     printf("\n\n%s", code);  <--- in order to make it match the fixed output '\n\n' should be deleted
2.     At the end of your code, there's something missing.
1 like 0 dislike
Hidden content!
*** * * ** * **
*
* * *** * ** *

* * *** * * **** * **** * ** ** * * *** * * * * * ** ** ** ** ** **
*
* * ** ** * *
*
* * *

* * ** *

* * * * ** * * ** * * * * * * * * ** * * ** *
*
* = * *
*
b +

*** = c + *

*** = d +

* *

* * * *** ** * * * * *



*
100/100 answered by (268 points)
0 0
It's correct lol you can't judge me
0 0
Well, that's because your output doesn't match with the fixed answer. Please take a look at this
printf("%c%c%c%c%c\n", a1, b1, c1, d1, e1);

Hint: You should delete something  :)

By the way, great job.
0 0
printf("%c%c%c%c%c", a1, b1, c1, d1, e1);

How's that?
0 0
That's correct.
1 like 0 dislike
Hidden content!
* * * ** ***
* **** * **** * *

int ** argc, char ** * {
** ***** char * *
* * ** *** * char * *
* ** ** * char ***
* * * *** char * ***
** * ** * char *****
** * * ***
** ** ** ** * * * input the letter to * * * **
*** ** * *
*** **** * * * * *** ** * * ** ** * * * * * ** * * * * * ** ** ** ** * ** ***
* ** * **** * * = * * + 3;
***** ** * ** = * * + 3;
* **** *** *** *** = * + 3;
*** * ** * *** * letterc = ** + 3;
* * ** * = * * + 3;
* * ** *
* **** * ** ***** * *** **** * * * * ** *** *
** *** ** **
** * * **** return 0;
}
100/100 answered
reshown by
0 0
-----------Re-judge-----------
Case 0: Wrong output
0 0
Nice, it is correct. You might be wondering why your automatically-generated score is 0.
That's because it expects its output to be only 'hello'. However, what your program showed was:
     Please input the letter to encode: ebiil
     hello

Anyway, great job. Full marks.
1 like 0 dislike
Hidden content!
*** * * ** *** **
* * * ** * ** * ** *

int * argc, char *argv[]) {
** ** * * * char **
** ** ** ** char letteri;
* ** * ** ** ** char * * *
* ** * char * **
* *** * * char ** *
***** * * ** * *
* ** ** * * ** ** * * input the letter to encode: *** ** * * **** *
*** ** * * *
** ** ** ** * ** ** ** **** * ** * ** ** * ** * **** * ****** *** * ** * * ***
* ** *** * * * *** * +3;
*** ** ***** * **** *** +3;
** * * ** * ** +3;
** * ** ** +3;
* *** * * * * * * +3;
* * * ** *
**** **
* * ** *** ** * ** * ** ****** ** **** *** ** *** *
* * *** * *
** * * ** * return 0;
}


INPUT
* * **
* ** * * *
OUTPUT
***** ** ** * ***
100/100 answered by (269 points)
0 0
Nice, it is correct. You might be wondering why your automatically-generated score is 0.
That's because it expects its output to be only 'hello'. However, what your program showed was:
     Please input the letter to encode: ebiil
     hello

Also, it's an online compiler, if you want to make a comment don't forget to use //. For example, //input ebiil
//output hello

Anyway, great job. Full marks.
0 0
prog.c:27:1: error: unknown type name 'INPUT'
 INPUT
 ^~~~~
prog.c:30:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OUTPUT'
 OUTPUT
 ^~~~~~
prog.c:30:1: error: unknown type name 'OUTPUT'
1 like 0 dislike
Hidden content!
** ** ** ** * ** **
*** * ** * * **

int argc, char ** {
* * * * char *** *
* * * * * char ** *
* ** ** * char *** *
** *** char *
* * ** * ** * char ****
**** * * **
*** *** * ***** * * * *** input the * * to ** * * * ** *
* ** *
*** * * * ** ** * **** ** ** ** * ***** *** * ** **** * **** **** **** * *** *** *
* ** ***
* ** * letter = letter + 3;
* * ** * * * = * * + 3;
** ** *** * **** **** = *** * + 3;
** * * * * * * = ** ** + 3;
*** * * * * * * * = ** + 3;
** ** * ** * *
*** * ** ** ***** * * * * * letter is * * * *** * ** *** * **** * *** *
* * *
**** * return 0;
}

INPUT
** *** * **
* * *****
**
* * **
100/100 answered by (290 points)
reshown by
0 0
Nice, it is correct. You might be wondering why your automatically-generated score is 0.
That's because it expects its output to be only 'hello'. However, what your program showed was:
     Please input the letter to encode: ebiil
     The encrypted letter is hello

Also, it's an online compiler, if you want to make a comment don't forget to use //. For example, //input ebiil
//output hello

Anyway, great job. Full marks.
0 0
prog.c:26:1: error: unknown type name 'INPUT'
 INPUT
 ^~~~~
prog.c:29:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OUTPUT'
 OUTPUT
 ^~~~~~
prog.c:29:1: error: unknown type name 'OUTPUT'
1 like 0 dislike
Hidden content!
#include ***** * * *

int main(int argc, char *argv[]) {
* * * ** * * lettera;
**** * ** ** *** ** * letterb;
* * *** * ** *** letterc;
** * ** * * * letterd;
* *** ** ** * *** *** lettere;
* * **** * ** ****
* ** * **** * * * ** ****** * %c %c %c * ** * * ** ***** *** * * * **** *** ** * *
* * *** * * * ***** ***** = lettera + 3;
** * ** * * *** * * = letterb + 3;
***** * * ** * *** * * = letterc + 3;
* ** ******* ** ** * * * = letterd + 3;
*** *** * *** * ** * ** ** = lettere + 3;
*** * **** ** * * ** ** * *** * ** *** ** *
* ** ** * ** * *** * * * ** *** * %c %c %c ****** * **** letterb, * * * * ** **
* * * * *
** ******** **** *** * * **** 0;
}

* * *
****
* * * * *
* * *
//hello
100/100 answered by (271 points)
edited by
0 0
Nice, it is correct. You might be wondering why your automatically-generated score is 0.
That's because it expects its output to be only 'hello'. However, what your program showed was:
     Please input the letter to encode: e b i i l
     h e l l o

Also, it's an online compiler, if you want to make a comment don't forget to use //. For example, //input ebiil
//output hello

Anyway, great job. Full marks.
0 0
prog.c:25:1: error: unknown type name 'INPUT'
 INPUT
 ^~~~~
prog.c:28:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OUTPUT'
 OUTPUT
 ^~~~~~
prog.c:28:1: error: unknown type name 'OUTPUT'
0 0
prog.c: In function 'main':
prog.c:10:5: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     scanf("%c %c %c %c %c", &lettera, &letterb, &letterc, &letterd, &lettere);
     ^~~~~
prog.c:10:5: warning: incompatible implicit declaration of built-in function 'scanf'
prog.c:10:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:17:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     printf("%c %c %c %c %c", lettera, letterb, letterc, letterd, lettere);
     ^~~~~~
prog.c:17:5: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:17:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.120.164
©2016-2025

Related questions

0 like 0 dislike
2 answers
[Normal] Essay (Open question) - asked Dec 12, 2017 in Chapter 2: Syntax structure of the C language by 許哲瑋 (449 points)
ID: 37081 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users