Can someone explain how to convert numbers into the words in c++? Thanks.?
961194
you can use /, % operator to extract digits. \nyou also have to make two void functions. which will translate numbers into digits. \n\nvoid data(int num)\n{\n  switch(num)             \n{\ncase 0: \n         break;\ncase 1: cout<<"One ";\n         break;\ncase 2: cout<<"Two ";\n         break;\ncase 3: cout<<"Three ";\n         break;\ncase 4: cout<<"Four ";\n         break;\ncase 5: cout<<"Five ";\n         break;\n}\nand just keep going till twenty.\nand then another function which convert numbers from 20-100 into words. \n\nvoid getdata(int num)\n{\n  if(num>=90)                     \n                                  \n{\n cout<<"Ninety ";\n less20(num-90);\n}\nelse if(num>=80)\n{\n cout<<"Eighty ";\n less20(num-80);\n}\nyou have to complete it.\nexample to extract the digits for first and tenth position.\ndigit=number%10;                     \nlast_two=digit;\nnumber=number/10;\ndigit=number%10;\nlast_two=(digit*10)+last_two;\n\nnow just figure out the positions. \nand you are good.
253284
#include <stdio.h>\n\nint main(void) {\n\nint i, j, count; //C Sucks, wait till you take java\n\nfor(i=1; i<=1000; i++){&#92;&#92;goes through all numbers 1 to 1000\n    count=0;\n    for(j=2; j<i; j++)&#92;&#92;goes through all numbers 2 to i\n    {\n     if(i%j==0)&#92;&#92;checks to see if it i is evenly div. by i\n        count++;\n    }//nested for\n    if (count ==0)\n        printf("%d&#92;n", i);\n}//for\n\nreturn 0;\n}//main\n\n\n//Hope that helps!
74472
Use ToString() with a format, like ToString("#.00"), as in...\n\nDim test As Double\ntest = 0\nSystem.Console.WriteLine(test.ToString("#.00"))
368941
I can help you with this program in C (not C++).\n\n#include <stdio.h>\n\nint a;\n\nvoid main(void)\n{\n   for(a = 0; a <= 1000; a++)\n   {\n       printf("%d&#92;n", a);\n   }\n}\n\nThe above program lists numbers starting from 0 to 1000.\nYou can modify the program to add up all those numbers if that is what you want.\n\n#include <stdio.h>\n\nint a, sum = 0;\n\nvoid main(void)\n{\n   for(a = 0; a <= 1000; a++)\n   {\n      printf("%d&#92;n", a);\n      sum = sum + a;\n   }\n   printf("Sum = %d", sum);\n}\n\nThis program prints and also finds the sum to 1000 numbers starting from 0!
1151029
try this for an example, you will have to modify the code, I won't do your homework for you, but this should help you out\n\n\n#include <iostream>\n#include <fstream>\n\nusing namespace std;\n\nbool Load(ifstream&);\nbool ReadData(ifstream&, char[],int&);\nvoid PrintData(const char[],int);\nvoid clear(ifstream&);\n\n\nvoid sort(char[],int);\nvoid swapValues(char&,char&);\nint indexOfSmallest(const char a[], int startIndex, int numberUsed);\n\n\nint main()\n{\nifstream file;\nint iSize;\nchar cData[100];\n\ntry\n{\nif(!Load(file))\nthrow "File Handle could not be acquired";\n\nfor(int i=0; i< 3; i++)\n{\nif(!ReadData(file,cData,iSize))\nthrow "Data could not be read";\ncout << iSize << endl;\nPrintData(cData,iSize);\nsort(cData,iSize);\nPrintData(cData,iSize);\n}\n\nfile.close();\n}\ncatch(char* szError)\n{\ncout << endl << "Error: " << szError << endl;\nexit(0x01);\n}\n\nreturn 0;\n}\n\nbool Load(ifstream& iFS)\n{\ntry\n{\niFS.open("c:&#92;test.txt",ios::in);\nif(!iFS.is_open())\nthrow false; \nthrow true;\n}\ncatch(bool bCode)\n{\nreturn bCode;\n}\n}\n\nbool ReadData(ifstream& iFS,char cData[], int& iSize)\n{\ntry\n{\niFS >> iSize;\nif(iSize < 0);\nelse\n{\nclear(iFS);\nfor(int i=0;i < iSize;i++)\niFS.get(cData[i]);\nclear(iFS);\n}\nthrow true;\n}\ncatch(bool bCode)\n{\nreturn bCode;\n}\n}\n\nvoid clear(ifstream& iFS)\n{\nchar c = '&#92;0';\nwhile(c!= '&#92;n' && !iFS.eof())\niFS.get(c);\nc='&#92;0';\n}\n\n\nvoid PrintData(const char cData[], int iSize)\n{\nfor(int i=0; i < iSize; i++)\ncout << cData[i];\ncout << endl;\n}\n\n\nvoid sort(char a[], int numberUsed)\n{\n    int indexOfNextSmallest;\n    int index;\n\n    for (index = 0; index < numberUsed - 1; index++)\n    {\nindexOfNextSmallest = indexOfSmallest(a, index, numberUsed);\n        swapValues(a[index], a[indexOfNextSmallest]);\n    }\n}\n\nvoid swapValues(char& v1, char& v2)\n{\n    char temp;\n    temp = v1;\n    v1 = v2;\n    v2 = temp;\n}\n\nint indexOfSmallest(const char a[], int startIndex, int numberUsed)\n{\n    int min = a[startIndex],\n        indexOfMin = startIndex;\n    int index;\n\n    for (index = startIndex + 1; index < numberUsed; index++)\n        if (a[index] < min)\n        {\n            min = a[index];\n            indexOfMin = index;\n        }\n\n    return indexOfMin;\n}
461876
Use Word's integrated equation editor:\n\nInsert > Object > Microsoft Equation 3.0\n\nThis will launch an equation editor that will allow you to put in almost any mathematical symbol/number, etc.\n\nHope this helps.
697721
First up you are going to need a compiler, you can get a free one here.\nhttp://www.borland.com/downloads/download_turbo.html\n\nInformation about it can be found here.\nhttp://www.turboexplorer.com/\n\nSome tutorials for c++ can be found here.\nhttp://www.cs.wustl.edu/~schmidt/C++/\n\nhttp://www.cplusplus.com/doc/tutorial/\n\nYou do not have to worry about memory allocation in C++, you can deal with it if you want, but you can avaoid it by using the keywords, 'new', 'delete', and 'delete[]'.\n\nRegarding the generation of random word segments, it would be done the same way as the random numbers are generated.\n\nIe, make an enum of these word segments,\nstring[] word_segments[5] = {"a", "an", "her", "ot", "etc"}\n\nWhen you get the random number, have it select a value from this array.\n\nword_segments[random_number];
312194
I am not sure if this is what you mean.\n\n#include <iostream>\n\nusing namespace std;\n\nvoid main() {\n\n    char ch;\n    cout << "Type in a character, then press enter.&#92;n";\n    cin >> ch;\n    cout << "&#92;nYou typed: ";\n    cout << ch;\n}\n\nThat will read one character from the keyboard for you.\nIt was intentionally made simple.\n\njack573
912485
there is no "code" for it. The compiler evaluates it at the compile time, and replaces with the actual number.\nThere is no way to write a function that would did that at run time, because at run time, there is not type information available - only addresses of variables not their sizes
618947
#include <iostream> \n#include <cstdlib> \n#include <iomanip> \n\nint make_odd(int h); \nvoid rec_call(char c, int s); \n\n\nint main( void) \n{ \n    cout << "Enter character to use in the diamond.&#92;t"; \n    char draw; \n    cin >> draw; \n    cin.ignore(1000, '&#92;n'); \n    cout << "How many rows in the diamond (make it an odd number)?&#92;t"; \n    int high; \n    cin >> high; \n    cin.ignore(1000, '&#92;n'); \n    high = (high % 2)? (high/2) + 1 : make_odd(high); \n    rec_call(draw, high); \n    cout << "&#92;n&#92;nPress Enter to Continue . . .&#92;t"; \n    cin.get(); \n    return 0; \n\n\n\n} \n\n\nint make_odd(int h) \n{ \n cout << "That is not an odd number&#92;nUsing " << (h + 1); \n return ((h / 2) + 1); \n\n\n} \n\n\nvoid rec_call(char c, int s)  // c = char to print s = rows to print \n{ \n static int i = 0; \n while(i < s) \n { \n      int width = s + i; \n      int len = 1 + (2 * i); \n      char temp[len + 1]; \n      for(int count = 0; count < len; count++) \n              temp[count] = c; \n      temp[len] = '&#92;0'; \n      cout << endl << setw(width) << temp; \n      i++; \n      rec_call(c, s); \n      if(i == s) \n      { \n         i++; \n         return; \n      } \n\n      cout << endl << setw(width) << temp; \n  } \n\n\n\n}
735637
i really dont understand your question for the student result sheet...anyway i am giving it a shot..\n\n#include<iostream.h>\n#include<conio.h>\n#include<stdio.h>\n\nvoid main()\n  {\n     string name,dob,rollno;\n      int mark[5],i,j;\n    clrscr();\n     cout <<"please enter the student's name :";\n     cin>>name\n     cout<<"&#92;n Please enter his/her roll number :";\n     cin>>rollno;\n     cout<<"&#92;n Please enter his/her date of birth in  dd-mm-yyyy format :";\n     cin>>dob;\n   cout<<"&#92;n&#92;n Please enter his marks in the 5 subjects :";\n    for(i=1;i<=5;i++)\n       {\n         cout<<"subject ["<<i<<"]  marks : ";\n         cin>>mark[i];\n       }\n\ncout<<"&#92;n press any key to generate the marksheet ..."\ngetch();\nclrscr();\n   \n   for (j=1;j<=80;j++)\n   {\n     cout<<"*";\n    }\n     cout<<"&#92;t&#92;t&#92;t Marksheet for student <<name<<endl;\n    cout<<"&#92;t Roll number   :"<<rollno;\n    cout<<"&#92;t&#92;t&#92;t&#92;t Date of birth :"<<dob\ncout<<"&#92;n&#92;n";\n  for (j=1;j<=80;j++)\n   {\n     cout<<"*";\n    }\n\n    for(i=1;i<=5;i++)\n         {  \n           cout<<"subject no ["<<i<<"] marks :"<<mark[i];\n        }\n\n\ncout<<"&#92;n&#92;n";\n  for (j=1;j<=80;j++)\n   {\n     cout<<"*";\n    }\n\ngetch();\n\n}\n\nwriting a game program in c++ is very tough and takes a lot of time...this link can help http://www.cprogramming.com/\n\nthis link seems ok  http://www.hotscripts.com/C_and_C++/Scripts_and_Programs/Games_and_Entertainment/index.html
670568
Try Planet Source Code:\n\nhttp://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=3270&lngWId=3\n\nThis one's in C++. You should be able to convert it back to C...
904666
Here is a super quick guide to learning to write numbers in binary...\n\nbinary uses 1/0 (on and off) to give value to numbers. This is why it is best used in computer language, because the computer can understand on and off. Now look at the following...\n\n1     \n2      \n4       \n8        \n16    \n32    \n64      \n128   \n\nNow,... notice the above... each number is equil to the number above it x2. this is the basis in learning binary...\n\nlets say we want to write the number  37....  we do the following...(read it from the bottom up)\n\n\n1        (there is one 1 in 1, this leaves us with 0 left over...)\n2        0\n4        (there is one 4 in 5, this leaves us with 1 left over....)\n8        0\n16      0\n32      (there is one 32 in 37, this leaves us with 5 left over...)\n64      0\n128    0\n\n\nso,... in binary, 37 would be   101001  (one 1, one 4, one32)\n\n\nusing the above we can learn to count to 10 !!!\n\n1   (1=1)\n01  (2=2)\n11  (2+1=3)\n001 (4=4)\n101 (4+1=5)\n011 (4+2=6)\n111 (4+2+1=7)\n0001 (8=8)\n1001 (8+1=9)\n0101 (8+2=10)\n\n\n\nthis is a very simple view of binary...\n\n\nhope this helps!!\n\n\n=)
691129
<> means 'not equal to'\n\nThe C/C++ equivalent is != \n\n a <> b : means 'a is not equal to b'\n 5 <> 6 : gives the value True\n 5 <> 5 : gives the value False
963773
It is done in C/C++. U can check that out in any of the windows programming books.
267921
You can turn these into proper C++ statements:\n\nread a, b\n\nlet max = a\n\nif max < b\n  let max = b\nendif\n\nprint max\n\nThis program assumes that a <> b.
557543
#include<iostream>\nusing namespace std;\nint main ()\n\n\n    {\nint number;\nint answer;\n    cout<<"Please enter number: ";\n    cin>>number;\n    \n    cout<<number<<"! = ";\n    answer = number;\n    while (number>1)\n\n\n        {\n        answer=answer*(number-1);\n        number--; \n    } \n\n    cout<<answer; \n    return 0; \n}