Dim x As String x = "HELLO" Dim tmpString As String tmpString = Nothing For j = 0 To x.Length - 1 Dim int int=x.Length - 1 int=int-j tmpString=x(j) Next
#include #include void main() { int rev num=0; while(num>0) { rev num=rev num*10+num%10; num=num%10; } return rev_num; } int main(); { int num=4562; printf("reverse of number is%d",reverse digit(num)); getch(); return o; }
Function is_prime(ByVal num As Integer) As Boolean If num < 0 Then num = num * -1 If num < 2 Then Return False If num Mod 2 = 0 Then Return num = 2 Dim max As Integer = Math.Sqrt(num) For div As Integer = 3 To max Step 2 If num Mod div = 0 Then Return False Next Return True End Function Sub Main() For num As Integer = 0 To 100 If is_prime(num) Then Console.Write(num) Console.WriteLine(" is prime") End If Next End Sub
#include<iostream> bool is_prime (const unsigned num) { return num%2 && num%3 && num%5 && num%7; } int main() { for (unsigned num=11; num<=100; ++num) if (is_prime (num)) std::cout<<num<<std::endl; } Output: 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
#include<iostream> bool is_composite (const size_t); bool is_prime (const size_t); int main() { for (size_t num=1; num<=10; ++num) if (is_composite (num)) std::cout << num << " is composite\n"; } bool is_composite (const size_t num) { if (num < 4U) return false; return !is_prime (num); } bool is_prime (const size_t num) { const size_t two = 2U; if (num < two) return false; if (!(num % two)) return num == two; const size_t max = static_cast<size_t>(sqrt (static_cast<double>(num))); for (size_t div = 3U; div <= max; div += two) if (!(num % div)) return false; return true; }
unsigned binary_to_gray (unsigned num) { return num ^ (num >> 1); } unsigned gray_to_binary (unsigned num) { /* note: assumes num is no more than 32-bits in length */ num ^= (num >> 16); num ^= (num >> 8); num ^= (num >> 4); num ^= (num >> 2); num ^= (num >> 1); return num ; }
Impossible to answer without a detailed description
num num num
In simple Python code: def convertToAngle(num): while True: if num < 0: num = 360 - num elif num > 360: num -= 360 else: break return num
#include<iostream> #include<sstream> #include<exception> std::string decimal_to_roman (unsigned num) { std::stringstream ss {}; while (num>0) { if (num>10000) throw std::range_error ( "ERROR: decimal_to_roman (unsigned num) [num is out of range]"); else if (num==10000) { ss<<"[M]"; num-=10000; } else if (num>=9000) { ss<<"[CM]"; num-=9000; } else if (num>=5000) { ss<<"[D]"; num-=5000; } else if (num>=4000) { ss<<"[CD]"; num-=4000; } else if (num>=1000) { ss<<"M"; num-=1000; } else if (num>=900) { ss<<"CM"; num-=900; } else if (num>=500) { ss<<"D"; num-=500; } else if (num>=400) { ss<<"CD"; num-=400; } else if (num>=100) { ss<<"C"; num-=100; } else if (num>=90) { ss<<"XC"; num-=90; } else if (num>=50) { ss<<"L"; num-=50; } else if (num>=40) { ss<<"XL"; num-=40; } else if (num>=10) { ss<<"X"; num-=10; } else if (num==9) { ss<<"IX"; num-=9; } else if (num>=5) { ss<<"V"; num-=5; } else if (num==4) { ss<<"IV"; num-=4; } else if (num>=1) { ss<<"I"; num-=1; } } return ss.str(); } int main (void) { for (unsigned n=1; n<=10000; ++n) { try { std::cout << n << "\t = " << decimal_to_roman(n) << std::endl; } catch (std::range_error& e) { std::cerr<<e.what()<<std::endl; break; } } }
num 1 is predator num 2 is the beast num 3 is mimi num 4 is peachy and num 5 is centi
Dim x As String x = "HELLO" Dim tmpString As String tmpString = Nothing For j = 0 To x.Length - 1 Dim int int=x.Length - 1 int=int-j tmpString=x(j) Next
Num Num Num........................ XD hehehe...........
#include #include void main() { int rev num=0; while(num>0) { rev num=rev num*10+num%10; num=num%10; } return rev_num; } int main(); { int num=4562; printf("reverse of number is%d",reverse digit(num)); getch(); return o; }
this is the script Harry: I,m harry potter, school is for losers, I,m totally awsome Snape: Harry Potter, you've been absent from potions class for 3 weeks and I have no choice but to (goes muffled)num num num num num num Harry Potter num num num (harry punches snape then plays saxaphone) awsome
#include<stdio.h> #include<math.h> bool is_prime(unsigned num) { unsigned max, factor; if (num<2) return false; if (!(num%2)) return num==2; max = (unsigned) sqrt((double)num) + 1.0; for (factor=3; factor<max; ++factor) if (!(num%factor)) return false; return true; } int main() { unsigned num; for (num=1; num<=100; ++num) if (is_prime(num)) printf ("%u is prime\n", num); return 0; }
Function is_prime(ByVal num As Integer) As Boolean If num < 0 Then num = num * -1 If num < 2 Then Return False If num Mod 2 = 0 Then Return num = 2 Dim max As Integer = Math.Sqrt(num) For div As Integer = 3 To max Step 2 If num Mod div = 0 Then Return False Next Return True End Function Sub Main() For num As Integer = 0 To 100 If is_prime(num) Then Console.Write(num) Console.WriteLine(" is prime") End If Next End Sub