0% found this document useful (0 votes)
6 views15 pages

Assignment - Suman Shrestha

Coursework

Uploaded by

aabishkarroka69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

Assignment - Suman Shrestha

Coursework

Uploaded by

aabishkarroka69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1.

WAP to display “hello world”, 5 times using a loop

2. WAP to Display an integer number from 5 to 10, using a loop


3. WAP to display numbers from 5 to 1, in depending order using a
loop.

4. Write a C program to find the sum of first ‘n’ natural numbers


5. Write a C Program to find the factorial of a number entered by user
using loop

6. Write a C program to find the sum of all the even numbers, and all
the odd numbers “separately” within the range of number entered
by user ( range is like : from 20 to 40)
7. Write a C Program to generate a multiplication table of a number
entered by user.

8. Write a C Program to Find whether a number entered by a user is


Prime or not
9. Write a C Program to generate a Fibonacci series up to n terms Like: 1
2 3 5 8 13 21...............

10. WAP to check whether a number entered by the user is palindrome


or not.
11. WAP to ask an integer as input one at a time until user enters zero ( 0
), if user enters zero, display the product of all the integers that the user
entered before. Make use of “break” keyword in your program
12. WAP to take an integers (could be odd or even) as input one at a
time; display the entered number only if it is an even number, otherwise
don’t display. Ask for new number until the user hits 3rd even number.
After user enter third even number, terminate the program with a
message, “now you entered total of three even numbers”. Also, display
the sum of those three even numbers at last.

#include <stdio.h>

int main() {

//SIR BATTI GONEEEEE…DONE BY AABISHKAR ROKA


int even_count = 0;
int even_sum = 0;
int num;

while (even_count<3) {
printf("Enter an integer: ");
scanf("%d", &num);

if (num%2==0) {
even_count++;
even_sum += num;
printf("You entered an even number: %d\n", num);
}
}

printf("Now you have entered a total of three even numbers.\n");


printf("Sum of the three even numbers: %d\n", even_sum);

return 0;
}
13. WAP to check whether a number is Armstrong or not? (user can
enter any length of integer)
14 Write a program in C that calculates the sum of digits entered by the
user successively until the sum reduces to a single digit number. For
example 12345=>1+2+3+4+5=15, 15=>1+5=6.
15. WAP to display all the Prime numbers which lies between 50 and
100.
16. WAP to display the factorial of all the integers from 1 to ’n’, where n
is entered by the user.

17. WAP to take ’n’ as input, and display the multiplication table of all
the integers from 1 to ’n’, as in the following screenshot
1. Ans

2. Ans
3. Ans

4. Ans
5. Ans

You might also like