1 / 3
Sep 2017

#include<stdio.h>
main()
{
int t,x,ans;
scanf("%d",&t);
while(t–)
{
x=fun(ans);
printf("%d",x);
}
}
int fun(int ans)
{
int n1,n2,rev1=0,rev2=0,add,rev=0;
scanf("%d%d",&n1,&n2);
while(n1!=0)
{
rev1=rev110;
rev1=rev1+n1%10;
n1=n1/10;
}
while(n2!=0)
{
rev2=rev2
10;
rev2=rev2+n2%10;
n2=n2/10;
}
add=rev1+rev2;
while(add!=0)
{
rev=rev*10;
rev=rev+add%10;
add=add/10;
}
ans=rev;
}

  • created

    Sep '17
  • last reply

    Nov '17
  • 2

    replies

  • 817

    views

  • 3

    users

what does the " t - " mean?

Neither you read “x” nor “ans”, so what do you expect ?
I mean, you don’t have to read the “x” but what with the “ans” ?

I see you read the numbers in the function “fun”, so you should run this function without any argument
like this :
x = fun();
if you expect that fun(); will return something, because i don’t see it in your code.

Example of function that returns something:

#include <stdio.h>  

int function();
int main()
{ 
    int x;
    x = function();
    printf("%d\n",x);
}
int function()
{
    int a;
    scanf("%d",&a);
    a +=2;
    return a;
}

//what could possibly go wrong ? :slight_smile:

1 month later

@rethu

  • i made 1st error in while loop i.e. t-
  • then u have to declare ur fun function
  • u did not declare r110 in r1=r110 and r210 in r2=r210
  • each undeclared identifier is reported only once for each function it appears in
  • control reaches end of non-void function

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 13 5d

Want to read more? Browse other topics in C and C++ or view latest topics.