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

Where is c used?

819


what is ur strangth & weekness

2026


What should malloc() do?

833


How can I run c program?

918


Are global variables static in c?

864


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

848


Define circular linked list.

777


What is define directive?

848


How can I generate floating-point random numbers?

786


What is meant by type casting?

812


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2941


What is c definition?

951


why wipro wase

2033


What is the difference between memcpy and memmove?

772


How do I determine whether a character is numeric, alphabetic, and so on?

847