0

Convert c to c++

#include<stdio.h> #include<math.h> long long int power(long long int a, long long int b, long long int P) { if (b == 1) return a; else return (((long long int)pow(a, b)) % P); } int main() { long long int P, G, x, a, y, b, ka, kb; P = 23; printf("The value of P : %lld\n", P); G = 9; printf("The value of G : %lld\n\n", G); a = 4; printf("The private key a for Alice : %lld\n", a); x = power(G, a, P); b = 3; printf("The private key b for Bob : %lld\n\n", b); y = power(G, b, P); ka = power(y, a, P); kb = power(x, b, P); printf("Secret key for the Alice is : %lld\n", ka); printf("Secret Key for the Bob is : %lld\n", kb); return 0; }

14th Apr 2019, 4:52 AM
Roshan Shinde
Roshan Shinde - avatar
4 ответов
+ 2
There is no need of.converting c to c++. They are backward compatible - meaning you can run c codes on c++ codes.
14th Apr 2019, 5:00 AM
Seniru
Seniru - avatar
+ 1
Simple! Just try it yourself. To get the C++ style you can change "printf" to "cout", add "#include <iostream>" and add "using namespace std;"
14th Apr 2019, 5:08 AM
Seniru
Seniru - avatar
+ 1
Thanks
14th Apr 2019, 5:09 AM
Roshan Shinde
Roshan Shinde - avatar
0
Sir...plz can you convert this..into c++ I know it can run..over c++ bt i was need c++ code
14th Apr 2019, 5:02 AM
Roshan Shinde
Roshan Shinde - avatar