0

How to print multiple data if set condition

a[]={1,2,3,4,5,6,7,8,9} How can I write a programme that will display data value below 5. meaning output will print 1,2,3,4,5 in C language

2nd Aug 2018, 1:03 AM
Kelvin
Kelvin - avatar
1 Réponse
0
You can just write a loop and use an if clause inside of it, to check if the value is smaller than 5. for (int i = 0; I < sizeof(a)/sizeof(a[0]); i++) { if (a[i] < 6) printf("%d", a[i]); }
26th May 2024, 7:31 PM
Jake Hempel