C Program Exercise Unit1 and Unit 2
C Program Exercise Unit1 and Unit 2
*
***
*****
*******
*********
*
* *
* *
* *
*********
*********
*******
*****
***
*
*********
* *
* *
* *
*
*
**
***
****
*****
****
***
**
*
Half Diamond Star Pattern
*
**
***
****
*****
****
***
**
*
Mirrored Half Diamond Star Pattern
2. Number pattern programs - Write a C program to print the given number patterns
Number pattern 1
11111
00000
11111
00000
11111
Number pattern 2
01010
01010
01010
01010
01010
Number pattern 3
11111
10001
10001
10001
11111
Number pattern 4
11111
11111
11011
11111
11111
Number pattern 5
10101
01010
10101
01010
10101
If…Else Exercises
1. Write a C program to find maximum between two numbers.
2. Write a C program to find maximum between three numbers.
3. Write a C program to check whether a number is negative, positive or zero.
4. Write a C program to check whether a number is divisible by 5 and 11 or not.
5. Write a C program to check whether a number is even or odd.
6. Write a C program to check whether a year is leap year or not.
7. Write a C program to check whether a character is alphabet or not.
8. Write a C program to input any alphabet and check whether it is vowel or consonant.
9. Write a C program to input any character and check whether it is alphabet, digit or special
character.
10. Write a C program to check whether a character is uppercase or lowercase alphabet.
11. Write a C program to input week number and print week day.
12. Write a C program to input month number and print number of days in that month.
13. Write a C program to count total number of notes in given amount.
14. Write a C program to input month number and print number of days in that month.
15. Write a C program to count total number of notes in given amount.
16. Write a C program to input angles of a triangle and check whether triangle is valid or not.
17. Write a C program to input all sides of a triangle and check whether triangle is valid or not.
18. Write a C program to check whether the triangle is equilateral, isosceles or scalene triangle.
19. Write a C program to find all roots of a quadratic equation.
20. Write a C program to calculate profit or loss.
21. Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics
and Computer. Calculate percentage and grade according to following:
24. Write a C program to convert specified days into years, weeks and days.
#include <stdio.h>
int main()
{
int days, years, weeks;
days = 1329;
// Converts days to years, weeks and days
years = days/365;
weeks = (days % 365)/7;
days = days- ((years*365) + (weeks*7));
return 0;
}