int main ()
         int a,b,c;


         return 0;

asked 12 Nov '15, 19:55

raseljpi11's gravatar image


edited 12 Nov '15, 20:39

Tamanna%20Nishat%20Rini's gravatar image

Tamanna Nishat Rini ♦♦

১. তুমি ইউজার থেকে ইনপুট নেয়ার আগেই যোগফল লিখে ফেলছো। a, b এর মান নাও নাই, কিন্তু আগেই c= a+b যোগ করে রাখছো।
২. তুমি ইনপুট নিতে চাচ্ছো দুইটা নাম্বার কিন্তু format spacifier (%d,%f,%lf এগুলো ফরম্যাট স্পেসিফায়ার) দিয়েছো একটা। এর জন্য প্রবলেম হচ্ছে। এগুলা একদমই বেসিক লেভেলের জিনিস। শুরুর দিকের। একটু বুঝে লজিক দিয়ে চিন্তা করে করার চেষ্টা করবা।

কোডটা হবে এমনঃ

scanf("%d %d",&a,&b);
c = a+b; 
permanent link

answered 12 Nov '15, 20:48

Tamanna%20Nishat%20Rini's gravatar image

Tamanna Nishat Rini ♦♦

When you run this your compiler it shows a warning: too many arguments for format [-Wformat-extra-args]| Why this happened? Here in your code you declare three integer =a,b,c.In scanf function you only use one %d but you passes two arguments=&a,&b.You don't declare another %d .That's why when you input 2 numbers like =1 and 2 .one has stored address of a ( &a) but 2 doesn't find his arguments .That's why it's overflow many numbers. Another wrong is you declare c=a+b -> scanf("%d",&a,&b). This is wrong .Why? Because at first you take input then compiler shows output . Here is your full code :

int main() { int a,b,c;//declare three integer variable scanf("%d %d",&a,&b);//give the two numbers in console c=a+b;//sum of two numbers. printf("%d",c);//c shows the two numbers sum. return 0;


permanent link

answered 12 Nov '15, 20:15

Iftekhar%20Joy's gravatar image

Iftekhar Joy

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Nov '15, 19:55

question was seen: 859 times

last updated: 12 Nov '15, 20:48