Add Them Up


This is a companion discussion topic for the original entry at https://toph.co/p/add-them-up
1 Like

What is wrong?

A = int(input())
B = int(input())
print(A+B)

2 Likes

Looks like you figured it out on your own. :slight_smile:

1 Like

WHATS WRONG?

#include<stdio.h>
int main()
{
    int A,B;

    scanf("%d",&A);
	scanf("%d",&B);	
    printf("%d",A+B);
    return 0;

}

This code is okay.

I checked your latest submission. You are getting “Compilation Error”. Please check what you are being told in the submission page. There will be a brief explanation of why your code is failing to compile.

1 Like

It accepted the first case.but the 2nd case is not correct…hlp pls

#include<stdio.h>
int main()
{
    int A,B,sum;
	A=4;
    B=5;
	sum=A+B;
	{printf("%d",sum);}
    return 0;
}

The reason is explained in the submission page:

:slight_smile:

You need to read the values of A and B from input.

I am confused though. You were already doing it correctly in your previous code. Why did you change that?

#include <bits/stdc++.h>

using namespace std;

int main() {
	unsigned long long ll2,ll1;
	cin >> ll1;
	cin >> ll2;
	
	cout <<ll1+ll2 << endl;
	return 0;
}

I got Wrong answer on 6th test case… help me out

Why use unsigned long long? :slight_smile:

I have solved a Problem but that is just running for 2 minutes.
what is wrong ?

@Wasif_719 Can you please share the submission ID?

when I submit my coding…it shows that its running…but when I refresh the page… everytime I can only see complitation error…
what’s wrong??

It is because there are syntactical errors in your code. You need to make sure the code you have written is valid C code.

When you get Compilation Error, pay close attention to what is said in the submission page. It will tell you about the exact issues in your code.

A post was split to a new topic: Programming Help

I wrote this code and it is running in Python IDLE.

def add(a,b):
    if a < 20000000 and b <20000000:
        print(a+b)
    else:
        pass
a = int(input())
b = int(input())
add(a,b)

But it is showing runtime error. Why?

@amin2783
The numbers are in the same line not in separate lines.

try using,

a, b = map(int, input().split())

instead of

a = int(input())
b = int(input())

Got it, thanks @touhidur

1 Like
#include <stdio.h>

int main() {
	int a,b;
	scanf("%d,%d",&a,&b);
	printf("%d",a+b);
	return 0;
}

What is wrong?

scanf("%d,%d",&a,&b);
         ^ This comma

:rofl: :rofl: :rofl:
The human compilation version of GCC

1 Like