General Programs2
General Programs2
Ph: 040-65538958/68/78
General programs:
If Condition:
1. Write a program input two numbers and find out the biggest number.
2. Write a program input three numbers and find out the biggest number.
3. Write a program input any number and check it is positive or negative
4. Write a program input any positive number and check it is even or odd
5. Write a program input any positive number and check it is even or odd without using %
symbol
6. Write a program input acno , name, current balance, transaction amount, transaction
code(d/w) calculate net balance.
7. Write a program input cno, cname,srno,erno,slab type(i/c/r) calculate units consumed
Conditions: if slab type is industry then unit rate is 5/-
If slab type is commercial then unit rate is 4/-
If slab type is residence then unit rate is 3/-
Calculate total bill.
8. Write a program input eno,ename,sal,designation(m/a/c) .
If designation is manager then bonus is 20% on his salary
If designation is analyst then bonus is 10% on his salary
If designation is clerk then bonus is 5% on his salary
Calculate totsal
9. Write a program input sno,sname,tm.
If tm>360 then print ‘First class’ If Tm>=300 and tm<360 then print ‘second class’
If tm<300 then print ‘third class’
Nested if:
1. Write a program input cno, cname,srno,erno,slab type(i/c/r) calculate units consumed
Conditions: if slab type is industry and units consumed <=100 then unit rate is 5/-
Else 6/- If slab type is commercial and units consumed <=100 then unit rate is 4/-
Else 5/- If slab type is residence then unit consumed <=100 then unit rate is 3/-
Else 4/- Calculate total bill.
Switch case:
1. Write a program input acno , name, current balance, transaction amount, transaction
code(d/w) calculate net balance.
2. Write a program to input any number from 1 to 10 and print in words.
3. Write a program to input any number from 1 to 100 and print in words.
Loops
For loop:
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5
1 2 3 4
1 2 3
1 2
2 2
3 3 3
4 4 4 4
5 5 5 5 5
1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1
6. program to print
a b c d e f g f edcba
a b c d e f f edcba
a b c d e edcba
a b c d dcb a
a b c cb a
a b b a
a a
While loop:
Arrays:
**Please give the all kinds of inputting values and what you expected as output must be specified. **
1. Write a program to generate the first 50 terms of Fibonacci series and print their sum and
average. E.g : 1 1 2 3 5 8 13 21 34 ……..
2. Write a program to find the sum of the series 1 - 1/2 2 + 1/32 – ¼2 + 1/52 - 1/62 + …….
5. Write a program that prints the following pattern using for loops.
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 5 3 2 1 0
10 9 8 5 2 1 0
10 9 5 1 0
10 5 0
8. Write a program to find GCD(greatest common divisor) or HCF (highest common factor)of two
numbers.
p. Gcd(a,b) = (a*b) / lcm(a,b)
q. Gcd(a,0) = a
Gcd(a,a) =a
Gcd(a,b) = gcd(a-b,b) if b < a
Gcd(a,b) = gcd(a,b-a) if a < b
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
13. Write a program to convert decimal to octal and Hexadecimal numbers and vice versa.
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
17. Write a program to swap two numbers without using a temporary variable.
18. Write a program in C to print “Hello World” without using semicolon anywhere in the
code.
19. Write a program in C to print a semicolon without using a semicolon anywhere in the
code.
20. Write a program to count the number of times the largest digit occur in a number.
e.g:- 22699 largest digit is : 9 no of occurrence is : 2
C programming codes
Hello world
Addition
Odd or Even
Check vowel
Leap year
Add digits
Factorial
Add n numbers
Swapping
Reverse number
Palindrome number
Diamond
Prime numbers
Fibonacci series
Linear search
Binary search
Reverse array
Merge arrays
Bubble sort
Insertion sort
Selection sort
Add matrices
Subtract matrices
Transpose matrix
Print string
String length
Compare strings
Copy string
Concatenate strings
Reverse string
Reverse number
Find palindrome
Delete vowels
Sort a string
Remove spaces
Change case
Swap strings
Character's frequency
Random numbers
Print date
Get IP address
Shutdown computer
Swapping
Binary to Decimal
Binary to Decimal,Octal,Hexadecimal
Roman to Decimal
Decimal to Binary
Palindrome
Fibonacci Numbers
Find Quadrant
Prime Number
Complex Numbers
Sum of Digits
Swap Numbers
Cos(x)
Sin(x)
X^N
Polynomial Series
ODD or EVEN
Armstrong Number
Perfect Number
Random Number
6. Write a program to find largest among three numbers using binary minus operator.
7. Write a program to find largest among three numbers using conditional operator
Swapping
String
1. Write a program to convert the string from upper case to lower case.
2. Write a program to convert the string from lower case to upper case.
6. Write a program for concatenation two strings without using string.h header file.
Matrix
Series
2. Write a program to find out the sum of series 1^2 + 2^2 + …. + n^2.
3. Write a program to find out the sum of series 1^3 + 2^3 + …. + n^3.
Array
Sorting
Recursion
1. Write a program to find the size of int without using sizeof operator.
2. Write a program to find the size of double without using sizeof operator.
3. Write a program to find the size of structure without using sizeof operator.
4. Write a program to find the size of union without using sizeof operator.
Searching
12. Write a program to find the surface area and volume of a cone.
13. Write a program to find the volume and surface area of sphere.
14. Write a program to find the perimeter of a circle, rectangle and triangle.
Other
Add Pointers
Area of Circle
ATM programing
Binary search
bubble sort -2
C Program find Positive Negative with Switch Case Without Conditional Operator
C Program to calcuate interest and total amount at the end of each year
C++ Programs
Facebook Page
Factorial Function In C
heap sort
History Of C
how 2 find a given number is positive or negative number in C without using relational and
conditional operator
Hsort
INORDER .
insertion sort
integer
Isort
Matrix Multiplication
Print 1 to 10 Series
Print a double pyramid
program to find greatest of 2 numbers without using relational and conditional operators
Qcksort
Qserch
quick sort
Search an array
Search An Element in Linked List
Shsort
Ssort
string
Substring Replacement
Subtract
WAP to add 1 and subtract 1 from value of a and b (Incremental / Decremental Operators)
WAP to create double dimension array of 2x3 matrix and display its Elements
WAP to enter records and also repeat the step if user wants to continue
WAP to find amount of given quantity of any company with 10% discount using switch case
WAP to find out Bigger and Equal number from three numbers (Ternary Operators)
WAP to find out Bigger number from two numbers (Ternary Operators)
WAP to find out Total Bill with discount according to conditions (Ternary Operators)
WAP To find the GCD (greatest common divisor) of two given integers
WAP to print series from 1 to 10 and find its square and cube
WAP to Sum
Write a C program to find both the largest and smallest number in a list of integers
#include<stdio.h>
int main(){
int i;
for(i=0;i<5;i++){
int i=10;
printf(" %d",i);
i++;
}
return 0;
}
Output 10 10 10 10 10