Having crossed the three-headed dog, Harry, Ron, and Hermoine went through a secret trap door in search of Sorcerer's stone. On the way, they passed through a room and found that the room has only one door opposite to them and the door through which they entered has shut once they entered the room. The door was very large with a four digit number imprinted on it. When Harry and Ron tried to open it by casting out spells, it didn't open. Having tried various spells both of them got fed up and they left the task to Hermoine. Hermoine on curiously observing the room found that a statement was written on the top of the room. It was written as follows "I will be always four" “I can only be opened when you add my first and last and enter it” “If you find a sign, you should not consider it” Help Hermoine break the code and open the door so that they can save the sorcerer's stone.
INPUT FORMAT:
Input consists of a single integer which is present on the door.
OUTPUT FORMAT:
The output is a single integer.
SAMPLE INPUT:
1001
SAMPLE OUTPUT:
2
Answers
Answered by
0
Answer:
#include<iostream>
using namespace std;
int main()
{
int a,i,r1,r3,a1[10];
cin>>a;
i=0;
while(a!=0)
{
r1=a%10;
a1[i]=r1;
i++;
a=a/10;
}
r3=a1[0]+a1[3];
cout<<r3;
}
Explanation:so here we are dividing the number and adding it to the array and we sum up the first and the last number of the array i.e we add '0th' location and '3rd' location.
Read more on Brainly.in - https://brainly.in/question/16708360#readmore
Answered by
1
Answer:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,first,last,sum;
cin>>n;
if(n > 1000 && n < 1111) {
first = n / 1000;
}
if (n > 100 && n < 1000) {
first = 0;
}
last=n%10;
sum = first + last;
cout<<sum;
return 0;
}
Explanation:
Similar questions
Science,
4 months ago
English,
4 months ago
Computer Science,
11 months ago
Computer Science,
11 months ago