The document outlines a series of programming tasks that involve user input and basic control structures in programming. Tasks include adding composite numbers until a prime is entered, checking for prime numbers, printing natural numbers with specific conditions, and calculating sums while handling negative inputs. Each task emphasizes the use of loops, breaks, and continues to manage user interactions effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views2 pages
Assignment 17 BreakContinue
The document outlines a series of programming tasks that involve user input and basic control structures in programming. Tasks include adding composite numbers until a prime is entered, checking for prime numbers, printing natural numbers with specific conditions, and calculating sums while handling negative inputs. Each task emphasizes the use of loops, breaks, and continues to manage user interactions effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
1. WAP to add 10 composite numbers entered by the user.
Program should stop adding the numbers as soon as the user
enters some prime number.
Input Output: Sum is :
1 , 12, 10,10,10,6,15,15,9,9 Sum is : 97 3 Sum is : 0 (Add until user enters prime number) 4, 6, 7 Sum is : 10
2. WAP to find whether a number is a prime number using break
keyword. 3. WAP to program print any 10 natural numbers. Program should stop printing if user enters number 10 itself. Your program should ask the user to enter any 10 natural numbers. Also, it should print them . However, if the user enters number 10, It should stop asking any further number. 4. WAP to calculate the sum of numbers (10 numbers max). If the user enters a negative number, the loop terminates and it should not ask for any other number. 5. WAP to take input from the user and print until he/she enters zero. 6. WAP to add 10 numbers entered by the user. If user enters any prime number, it should skip adding that prime number and ask for the next number from the user.
Input Output: Sum is :
1 , 12, 10,10,10,6,15,15,9,9 Sum is : 97 1, 2,3,4,5,6,7,8,9,10 Sum is : 38 (skip adding prime numbers) 2, 3, 7,10,3,3,3,3,3,3 Sum is : 10 ( Rest all are prime numbers) 7. WAP to program print any 10 natural numbers. Program should SKIP printing if user enters number 10 itself. Your program should ask the user to enter any 10 natural numbers. Also, it should print them . However, if the user enters number 10, It should not print it. 8. WAP to calculate the sum of numbers (10 numbers max). If the user enters a negative number, it should not add that number and it should ask for any other number. 9. WAP to take input from the user and print until he/she enters zero. However, if the user enters any number which is a multiple of 10, it should skip printing it. Rest all numbers entered by the user should be printed. [use loop, break and continue] 10. Write a C program to print sum of odd numbers between 0 and 10. [Use loop and continue]