Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a program that accepts a date from the user in the form mm/dd/yyyy and

ID: 3634355 • Letter: 1

Question






1. Write a program that accepts a date from the user in the form mm/dd/yyyy and then displays it in the form month dd, yyyy, where month is the name of the month:

Enter the date(mm/dd/yyyy): 2/17/2011
You entered the date February 17, 2011
Store the month names in an array that contains pointer to string.

------------------------------------------------------------------------------------------------------

2.Write a complete C programming to add two very large numbers together as follows:
Enter the first number
1999999999999999999999999999999999999999999996667766999999
Enter the second number
888888888888888888888888888888888888888888888888888888888888888888888888
Sum is
Display the total here



C Programming please!!! not JAVA!
Thanks ~

Explanation / Answer

Please Rate: Thanks
By the cramster rules ask only one at a time. Please post question individually.
Now i send the solutions for both. It surely help you


Program1:

 #include <stdio.h>
#include <conio.h>
int main()
{int day,month,year;
char names[12][9]={"January","February","March","April","May","June",
              "July","August","September","October","November","December"};
char *p[12];
int i;
for(i=0;i<12;i++)
    p[i]=names[i];
printf("Enter a date you wish to identify in the form of mm/dd/yyyy ");
scanf("%d/%d/%d",&month,&day,&year);
printf("You entered the date %s %d, %d ",p[month-1],day,year);
getch();
return 0;
}

 

--------------------------------------------------------------------------------------------------------

Program 2. 

I dont know if you want the program output to be in hexadeciaml, to the power of, or as a very long integer as you are showing in your example, but here is the program using three double variables, the double holds quite a bit of memory space so it should be fine for what you are after, the output of the program will show it in a power of form for when the numbers get out of hand so for example 1,978,965,374,387 would equate to something like 1,979e+324 where e+ is showing it to be to the power of.

Here is the program:


# include <iostream>
using namespace std;

//main driver
int main ()
{
double num1, num2, answer;

cout << "Please enter the first of 2 numbers: " << endl;

cin >> num1;

cout << "Please enter the second of 2 numbers: " << endl;

cin >> num2;

answer = num1 + num2;

cout << "The answer is: " << answer << endl;

//pauses the program on screen
system("pause");
return 0;
}

I'm pretty sure this will work in c, as they are the same language. But if the printing doesn't work you can change the "cout << answer" to printf("answer") or something along those lines.

-----------------------------------------

Another way for the program 2 is

#include <stdio.h>
#include <conio.h>
void input(char[]);
int add(char[],char[],char[]);
void print(char[],int,int);
int finish(char[],int,char[],int,int,int);
int main()
{char num1[256],num2[256],sum[257];
int i,digits;
for(i=0;i<257;i++)
     sum[i]='';
input(num1);
input(num2);
digits=add(num1,num2,sum);
print(num1,256,0);
printf(" + ");
print(num2,256,0);
printf(" = ");
print(sum,257,digits);
printf(" ");
getch();
return 0;
}
void input(char n[])
{
printf("Enter a number: ");
fgets(n, 256, stdin);
}
void print(char n[],int m,int code)
{int i;
if(code==0)
   for (i=0;i<m;i++)
      {if(n[i]=='')
          return;
       printf("%c",n[i]);
       }
else
   {for (i=code-1;i>=0;i--)
      {if(n[i]!='')
        printf("%c",n[i]);
       }
   }
}
int add(char a[],char b[],char c[])
{int i=0,j=0,k=0,carry=0,t,digits;
int done=1;
while(a[i]!='')
     i++;
while(b[j]!='')
      j++;

i-=2;
j-=2;
while (done==1)
    {t=a[i]-48+b[j]-48+carry;
     carry=t/10;
     c[k]=t%10+48;

     i--;
     j--;
     k++;    
     if(j<0)
         {digits=finish(a,i,c,k,carry,j);
          return digits;
          }
     if(i<0)
          {digits=finish(b,j,c,k,carry,i);
           return digits;
           }
     }    
}
int finish(char a[],int i,char c[],int j,int carry,int k)
  {int t;
  if(k>=0)
      return j;
   while(i>=0)
     {t=a[i]-48+carry;
      carry=t/10;
      c[j]=t%10+48; 
      i--;
       j++;
       }
if(carry>0)
    c[j++]=carry+48;
    return j;
    }