Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to enter n integers in C++
How to enter n integers in C++
First, the user is prompted to enter the number of integers to be entered.

Then input n integers in a loop.

Code:

# include & ltstdio.h & gt

void main()

{

int i=0,n;

Int integer;

Printf ("Enter the number of integers to be entered:");

scanf("%d ",& ampn);

While (I<n)

{

Printf ("Enter %d integer:", I+1);

Scanf("%d ",& integer);

printf(" Output % d integer:% d \ n \ n ",i+ 1,integer);

i++;

}

}

Results:

Enter the number of integers to be entered: 4.

Enter the 1 th integer: 12.

Output the 1 th integer: 12.

Enter the second integer: 54.

Output the second integer: 54.

Enter the third integer: 89.

Output the third integer: 89

Enter the fourth integer: 67.

Output the fourth integer: 67

Press any key to continue.