Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having trouble creating a three loop program in C. i can\'t make my program

ID: 3794627 • Letter: I

Question

I'm having trouble creating a three loop program in C. i can't make my program stop when pressing -1. i can only continue adding numbers including -1.

this is my code. Please help and my assignment instruction

Instructions:

Create a program that asks the user to enter a number from 1 to 25.

Print the statement “I'd rather be doing something else” the number of times entered by the user using a for loop.

Print the statement “Programming is easy” the same number of times using a while loop.

Print the statement “I like to have fun” the same number of times using a do/while loop.

Next, prompt the user to enter a series of numbers until the user enters a -1 to stop.

As long as the number is not -1, add the input number to an ongoing sum and print the sum and the number on the screen.

When the user enters a -1 print the message “Have a Great Day :)” and end the program. –the -1 should not be added to the sum.

#define _CRT_SECURE_NO_WARNINGS 1
#include

int main()

{
   //Create a program that asks the user to enter a number from 1 to 25

   int count = 25,
       numb = 0,
       summ = 0;

   printf("You will enter numbers from 1 to 25 ");

   //Print the statement “I'd rather be doing something else” the number of times entered by the user using a for loop
       for (numb = 0; numb < count && numb != -1; numb++)
       {
           int count = 25;
               numb = 0;
               int sum = 0;
           printf("I'd rather be doing something else and   Enter an integer: %d of 25: ", numb + 1);
           scanf("%d", &numb);
           //Print the statement “I like to have fun” the same number of times using a do/while loop
           do {
               sum = numb + numb;

           } while (numb > count);
           printf(" I like to have fun %d ", sum);          
       }
      
       //Print the statement “Programming is easy” the same number of times using a while loop
       while (numb < count && numb + numb);
       {
           printf("Programming is easy ");
       }
       if (numb = -1)
       {
           printf("Have a great day :)", -1);
       }

       return 0;
}

Explanation / Answer

#iinclude<stdiod.h>

Void main()

{

int num,count,sum ;

printf("Enter a value from 1 to 25") ;

   scanf ("%d",&num) ;

   for(count = 1 ; count <= num ; count++)

   {

print("I'd rather be doing something else %d ",count) ;

   }

   count = 1 ;

while( count <= 25 )

   {

   printf ("Prorammging is easy %d ",count) ;

}

count = 0 ;

do

{

   count++ ;

   printf ("I like to have fun %d ",count) ;

}while(count < 25) ;

   printf (" Enter a seres of nnumbers, Enter -1 to terminate ") ;

while( 1 )

   {

   scanf("%d",&num) ;

   if( num == -1 )

   {

   break ;

  }

else

{

sum = sum + num ;

}

}

printf ("The sum is %d ",sum) ;

return 0 ;

}

  

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote