|
|
IGNOU > IGNOU Assignments > BCA > BCA 2007 Assignments >C++ and Object Oriented Programming
IGNOU BCA Assignments
Question 2: Write a program in C++ that transforms an extended name into its initial form, for example Sudhansh Kumar Sharma to S. K. Sharma.
Ans:
Class string {
Private
Char * ptr
Public;
String()
{
*ptr = “Ashish”
}
String (char & na)
{
ptr = na;
}
string, string (string * nn)
{
ptr, n nptr;
}
string operator + (string a)
{
while (*ptr! = NULL)
{
ptr ++;
}
ptr --;
while (a ptr! = NULL)
{
* ptr = *a.ptr)
ptr ++;
a. ptr;
}
* ptr = 10;
}
string ()
{}
void (mp/string & a)
{
if/str comp (ptr, a) == 6)
out <<”string are equal”;
out <<”string are not equal”;
};
void main()
}
string S (“Rakesh”);
String R (& S);
R print0;
String L(“kumar”);
String P;
P = L+R
P. prin()
R. Cmp (&s);
}
Question 3: Write a program that calculate tomorrow’s date i.e. if you input a date 28/02/2000 then it should return 29/02/2000 because year 2000 was a leap year; similarly your program should take care of all the aspects such that which month have 28, 29,30, 31 days. If input is 31/12/2006 then output should be 01/01/2007.So change of date/month/year should be handled properly.
Ans:
Class calender {
Public
{ int base 7;
string Mon [] = {‘Jan’, ‘Feb’, ‘Mar’, ‘April’, ‘May’, ‘June’, ‘Jul’, ‘Aug’, ‘Sep’, ‘Oct’, ‘Nov’, ‘Dec’}
int dd = [ ] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
int, I, j, d, m, yy, di;
For (I=0, I<12, I++)
If (args [I] eached (Mon[I]);
Break;
}
M = I;
Yy = (Args [2]);
If (M=1 || M = 3|| M = 5|| M=7|| M = 8|| M = 10||, M == 12|)
d= 31;
else if (m==4||M == 6 || M == 8 || M ++10)
d=30;
elseif (yy/54 = 0)
d=28;
else
d = 29;
dt = 0
for (I=0; <M; I++)
dt = dt + dd[I]
B = (B+(Y-2000) * 365 + (Y-2000)/4+dt)%7
Cut << (“sum\Mon\Tue\Wed\Thu\Fri\Sat\”);
For (K=1; K<b; k++)
Cut << (“it”);
For (i=1, I<d; I++)
{K = K+1;
Cut << (i+”t”);
If (K==7)
{ K=0;
Cut << ();
}
}
}
}
 
|
|