+ 2
i had a test for u guys. example : input:253 output: 2 5 3
7 odpowiedzi
+ 3
#include <iostream>
using namespace std;
int a=253, x,y,z;
int main()
{
x=a/100;
y= (a-x*100)/10;
z= (a-x*100-y*10);
cout << x << endl;
cout << y << endl;
cout << z << endl;
return 0;
}
+ 1
One of lot of ways:
string s;
getline(cin, s);
for(char c: s)
cout << c << endl;
+ 1
how abt
input :253
output :
4
25
9
4+25+9=38
+ 1
get the number from user
convert it into reverse and then print the remainders by dividing the reverse by 10,and modifying the reverse no. into a 2 digit no. by eliminating the last digit
+ 1
your answer:
#include <iostream>
using namespace std;
int main() {
int i;
cout<<"enter a number: \n";
cin>>i;
void rev(int& x);
rev(i);
while(i!=0)
{
cout<<i%10<<endl;
i=i/10;
}
return 0;
}
void rev(int& x)
{
int s=0,r;
while(x!=0)
{
r=x%10;
x=x/10;
s=s*10+r;
}
x=s;
}
0
include "iostream.h"
void main () {
Int a[2];
cout<<" input number";cin>>a[2]:
for(int b=0; b<=2 ; b++;)
{cout<<a[b] <<endl;
}
}
0
One of ways to solve second case:
string s;
int sum = 0;
getline(cin, s);
for(char c: s) {
sum += ((c - '0') * (c - '0'));
cout << ((c - '0') * (c - '0')) << endl;
}
cout << (s[0] - '0') * (s[0] - '0');
for(int i = 1; i < s.length(); i++)
cout << '+' << ((s[i] - '0') * (s[i] - '0'));
cout << '=' << sum << endl;