int myArray[N]; //where N is a constant
int mySum = 0;
...
for (int arrayIndex1 = 0; arrayIndex1 <>
{
cin >> myArray[arrayIndex1];
}
...
for (int int arrayIndex2 = 0; arrayIndex2 <>
{
mySum +=myArray[arrayIndex2];
}
...
I had problems in making it when I was in first year.
int numer;
getche==number;
if (number ==1); printf("one");
if(number==100) printf("one hundred");
like that u can make it, but this approach will be very lenghty & bogus.
/* PROGRAM TO CONVERT THE NUMREIC FIGURES INTO THE WORDS */
#include
#include
void toWords(long,char[]);
char *one[]={" "," one"," two"," three"," four"," five"," six",
"seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen",
"fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty",
"sixty","seventy"," eighty"," ninety"};
void main()
{
long n;
clrscr();
printf("ENTER ANY 9 DIGIT NO.-> ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
toWords((n/10000000),"crore");
toWords(((n/100000)%100),"lakh");
toWords(((n/1000)%100),"thousand");
toWords(((n/100)%10),"hundred");
toWords((n%100)," ");
}
getch();
}
void toWords(long n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
if(n)printf("%s ",ch);
}
#include
#include
#include
void main()
{
char inp[20],revinp[20],flag=0;
clrscr();
int len=0,i=0,j=0;
printf("enter any word");
gets(inp);
len=strlen(inp);
for(i=len-1;i>=0;i--)
{
revinp[j]=inp;
j++;
}
revinp[j]='\0';
puts(inp);
printf("\n");
puts(revinp);
for(i=0;i
{
if(inp!=revinp)
{
flag=1;
printf("the word is not palendrom");
break;
}
}
if(flag==0)
printf("the entered word is palendrome");
getch();
}
#include
#include
void toWords(long,char[]);
char *one[]={"","one ","two ","three ","four ","five ","six ",
"seven ","eight ","Nine ","ten ","eleven ","twelve ","thirteen ",
"fourteen ","fifteen ","sixteen ","seventeen ","eighteen ","nineteen "};
char *ten[]={"","","twenty ","thirty ","forty ","fifty ",
"sixty ","seventy ","eighty ","ninety "};
void main()
{
long n;
clrscr();
printf("ENTER ANY 9 DIGIT NO.-> ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
toWords((n/10000000),"crore ");
toWords(((n/100000)%100),"lakh ");
toWords(((n/1000)%100),"thousand ");
toWords(((n/100)%10),"hundred ");
toWords((n%100),"");
}
getch();
}
void toWords(long n,char ch[])
{
(n>19)?printf("%s%s",ten[n/10],one[n%10]):printf("%s",one[n]);
if(n)printf("%s",ch);
}

No comments:
Post a Comment