Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a c programme for add of two numbers with out use of
arthematic operators

Answer Posted / ria

/*error!!! in this program if we give 28-02-2012 to 03-03-2012 then correct output is not showing*/


#include<stdio.h>
#include<conio.h>
#include<math.h>


int func(int x)
{
int y=0;
switch(x)
{
case 1: y=0;
break;
case 2: y=31;
break;
case 3: y=59;
break;
case 4: y=90;
break;
case 5: y=120;
break;
case 6: y=151;
break;
case 7: y=181;
break;
case 8: y=212;
break;
case 9: y=243;
break;
case 10: y=273;
break;
case 11: y=304;
break;
case 12: y=334;
break;
}
return y;
}


void main()
{
int day1,mon1,year1,day2,mon2,year2,ref,dd1,dd2,i;

printf("\n enter first day,month,year: ");
scanf("%d%d%d",&day1,&mon1,&year1);
printf("\n enter second day,month,year: ");
scanf("%d%d%d",&day2,&mon2,&year2);
ref=year1;
dd1=func(mon1);
dd1=dd1+day1;
dd2=0;
for(i=ref;i<year2;i++)
{
if(i%100==0)
{
if(i%400==0)
dd2++;
}
else
if(i%4==0)
dd2++;
}

dd2=dd2+func(mon2)+day2+((year2-ref)*365);
printf("\n no of days= %d",abs(dd2-dd1));
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are # pragma staments?

2041


Explain what is the benefit of using #define to declare a constant?

1175


What is pragma c?

1112


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

1026


How can I remove the leading spaces from a string?

1155


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1458


What is pointer in c?

1190


Why #include is used in c language?

1046


What is dynamic variable in c?

1026


Why we use void main in c?

1161


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1856


What is console in c language?

1096


How #define works?

1098


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1250


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1950