0
using scanf instead of cin for multiple inputs
1. is it better to use scanf and printf instead of cin and cout? advantages of scanf and printf? 2. how to i get a pop-box in sololearn for the user to enter values with scanf or cin ? 3. is it possible to consolidate multiple inputs into scanf function or cin? #include <iostream> #include "stdio.h" using namespace std; int main() { int a, b; printf("enter a number! \n"); scanf("%d %d ", &a &b); int sum=a+b; printf("The value sum is %d\n", sum); //current output:The value sum is 2147344384 without the user being prompted to enter values for a and b. return 0; } Thank you, i appreciate your assistance
4 Réponses
+ 8
cin >> a >> b;
Split multiple input into different lines, e.g.
3
4
+ 7
2. it is not possible here
+ 3
printf and scanf is C Style syntax. It's better to use
C++ syntax (cout, cin) if you're learning C++.
0
thank you guys