In: Computer Science
Read three integers from user input.
Reading integers from user input in different languages are different. Here I'm giving you how you can read three integers from user input and display the entered integers in C and C++:
1.C
#include <stdio.h>
int main() {
int a,b,c; //3 integers to store value
printf("Enter 3 integers: "); //printing message to enter integers
scanf("%d %d %d",&a,&b,&c); //reading integers
printf("The integers are : \ta = %d \tb = %d \tc = %d",a,b,c); //printing a,b,c
return 0;
}
OUTPUT:
2.C++
#include <iostream>
int main() {
int a,b,c; //3 integers to store value
std::cout<<"Enter 3 integers: "; //printing message to enter integers
std::cin>>a>>b>>c; //reading integers
std::cout<<"\nThe integers are : \ta ="<<a<<"\tb ="<<b<<"\tc ="<<c; //printing a,b,c
return 0;
}
OUTPUT: