123456
int x; std::cin >> x; x %= 9; if (x == 0) x = 9; std::cout << x;
12345678910111213141516171819202122
#include <iostream> using namespace std; int main(){ int t=0; int q; int num; cout<<"enter no"; cin>>num; while(num>0){ q=num%10; num=num/10; t=t+q; } cout<<t; return 0; }