Commit 76dd6687 authored by Gandla Sowjanya Rani's avatar Gandla Sowjanya Rani

changes commited

parent 69dbfaa7
#include<stdio.h>
void main()
{
int num,a,k=0,b[3],c[3],j=0,ch1,ch2,v,rem=0,rem1=0,rem2=0,val=0,num2,val1=0,aa=0,bb=0,cc=0,def=9,zero=0,val2=0,cnt=0,num3=0;
printf("\t\t\t\t\t\t\t*****************************************");
printf("\n\n\t\t\t\t\t\t\t\tenter a 3 digit number: ");
scanf("%d",&num);
num2=num;
num3=num;
while(num3!=0)
{
a=num3%10;
cnt=cnt+1;
num3=num3/10;
}
if(cnt==3)
{
while(num!=0)
{
a=num%10;
k=k+a;
num=num/10;
}
val=num2-k;
val1=val;
val2=val1;
while(val!=0)
{
a=val%10;
b[j]=a;
j++;
val=val/10;
}
aa=val1%10;
val1=val1/10;
bb=val1%10;
val1=val1/10;
cc=val1%10;
val1=val1/10;
if(val2==99)
{
c[0]=0;
for(int p=1,v=1;p>=0;p--,v++)
c[v]=b[p];
}
else
{
for(int p=2,v=0;p>=0;p--,v++)
c[v]=b[p];
}
printf("\n\t\t\t\t\t\t\t\tenter choice: ");
scanf("%d",&ch1);
printf("\n\t\t\t\t\t\t\t\tenter choice: ");
scanf("%d",&ch2);
if(ch1<=2&&ch2<=2)
{
if(c[ch1]+c[ch2]==cc||c[ch1]+c[ch2]==bb||c[ch1]+c[ch2]==aa)
printf("\n\t\t\t\t\t\t\t\tAnswer is : %d",def);
else
{
for(k=0;k<3;k++)
{
if(k==ch1)
{
rem=c[k];
}
if(k==ch2)
{
rem1=c[k];
}
}
rem2=rem+rem1;
if(rem2==18)
{
printf("\n\t\t\t\t\t\t\t\tAnswer is : %d",zero);//def
}
else if(rem2==9)
{
printf("\n\t\t\t\t\t\t\t\tAnswer is : %d",zero);
}
else if(rem2>9)
{
rem2=18-rem2;
printf("\n\t\t\t\t\t\t\t\tAnswer is : %d",rem2);
}
else if(rem2<9)
{
rem2=9-rem2;
printf("\n\t\t\t\t\t\t\t\tAnswer is : %d",rem2);
printf("\n\n");
}
}
}
else
printf("\n\t\t\t\t\t\t\t\tenter valid choice\n");
}
else
{
printf("\n\t\t\t\t\t\t\t\tplease enter 3 digit number");
}
printf("\n\t\t\t\t\t\t\t*****************************************\n");
printf("\n");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment