घ Write a for loop that prints firstNumber...-10. Ex: If the input is: -3 the output is -3-2-18 1 #include 2 3

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

घ Write a for loop that prints firstNumber...-10. Ex: If the input is: -3 the output is -3-2-18 1 #include 2 3

Post by correctanswer »

 1
1 (30.34 KiB) Viewed 123 times
घ Write a for loop that prints firstNumber...-10. Ex: If the input is: -3 the output is -3-2-18 1 #include <stdio.h> 2 3 int main(void) 4 int firstNumber; 5 int i; 6 7 scanf("%d", &firstNumber); 9 for(i-firstNumber:1-0;1-) { printf("%d", 1); 10 11 } 12 13 return 0; 14 Check Try again X The loop starts with the value input into firstNumber, and ends with 0 due to the <- in the loop expression if first Number is assigned to a number greater than 0 the loop condition is immediately false and the loop is never entered 1: Compare output Output differs See highlighte below
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply