INDEX
- C program: Input integer and display it's Negative or not
- C program: Input Age and display Adult or Minor
- C program: Absolute Value Program
- C program: Greatest of two (2) Integers Program
- C program: Greatest of three (3) Numbers Program
- C program: Leap Year Program
- C program: Quadratic Equation Program
- C program: Accept marks of a student, and the maximum marks then display "PASS" or "FAIL"
[If Percentage >= 35 then PASS otherwise FAIL]
Ex:
Enter Marks Scored: 46
Enter Maximum Marks: 70
Percentage = 65.71
Result = PASS - C program: Accept coefficients and constants of a quadratic equation ax^2 + bx + c = 0, then display whether it has real or imaginary roots.
[if b^2-4ac>=0 then REAL ROOTS otherwise IMAGINARY ROOTS]
Ex:
Enter cooeficient of x^2 (a): 5
Enter coefficient of x (b): 12
Enter constant (c): 3
Roots are REAL - C program: Accept length of diagonals of a quadrialteral, then display the nature of quadrilateral thus formed.
[equal diagonals => Rectangle, Square, or isosceles trapezium, otherwise => any other triangle]
Ex:
Enter length of diagonal1: 5
Enter length of diagonal2: 7
Result= Any quadrilateral otherthan Rectangle, Square and isosceles trapezium - C program:Accept any integer and then display whether it is a positive, negative or zero
Ex:
Enter any integer: -23
The number entered is NEGATIVE - C program: Accept length of the three sides of a triangle and then display what kind of triangle it forms
[All sides equal: Equilateral triangle,
Two sides equal: Isosceles triangle
No side equal: Scalene triangle] - C program: Accept length of sides of a triangle, and display whether it forms a right angled triangle or not.
[(longest side)^2 = (other side1)^2 + (other side2)^2 ]
Ex:
Enter Longest side(a): 13
Enter Next side(b): 12
Enter Remaining side(c): 5
Result: They form RIGHT ANGLED TRIANGLE - C program: Accept Total Marks scored, and Maximum Marks of a student in an Exam, Then display Percentage and also display Grade as per the following chart;
[Percentage => 75 - 100, Grade = A
60 - less than 75, Grade = B
45 - less than 60, Grade = C
33 - less than 45, Grade = D
others, Grade = E or Fail ]
Ex:
Enter Marks Scored: 46
Enter Maximum Marks: 70
Percentage = 65.71
Grade: B - C program: Accept the coefficients and constants of two linear equations in 2 variables; a1x + b1y + c= 0, and a2x + b2y + c2 = 0. Then display whether they form intersecting lines, parallel lines or co-inciding lines.
[a1/a2 not equal to b1/b2 => intersecting lines,
a1/a2 = b1/b2 = c1/c2 => co-incident lines
a1/a2 = b1/b2 not equal to c1/c2 => parallel lines ]
Ex:
Equation1 a1x + b1y + c1 = 0
Enter a1: 2
Enter b1: 3
Enter c1: 7
Equation2 a2x + b2y + c2 = 0
Enter a2: 3
Enter b2: 5
Enter c2: 2
Result: Lines are INTERSECTING - C program: Accept monthly sales amount of a sales person, and then display his/her commission earned as per the following chart;
Sales Amount (INR) Commission Earned
0 - less then 25,000 3% of SA
25,000 - <50,000 5% of SA
50,000 - <75,000 7% of SA
75,000 - <1,00,000 9% of SA
>= 1,00,000 11% of SA
Ex:
Enter Monthly Sale Amount (in INR): 62000
Commission earned = 4340 - C program: Accept no. of electrical energy consumed (in units), then display the Bill Amount as per the following chart;
Units Consumed Rate (in INR/unit)
0-75 3.25/unit
next 75 units 3.75/unit
next 100 units 4.25/unit
next 150 units 4.75/unit
next 200 units 5.25/unit
above 600 units 5.75/unit
Ex:
Enter No. of units consumed: 235
Your Bill Value is = 886.25 - C program: A program to accept two numbers and an operator (+,-,*,/,%). Then based upon the operator entered, perform the necessary calculation and display the answer. The program should give appropriate message if any wrong operator is input.
EX:
Enter Number1: 7
Enter Number2: 11
Enter Operator (+,-,*,/, or %): +
Result = 18
- C program: A program to accept the month number and then display the number of days in that month. The program should give appropriate message if any wrong month number is input.
[Taking Month1 as January and Month12 as December]
Ex:
Enter Month Number: 5
No. of days in month-5 is = 31
- C program: A program to display the following menu, and then do the necessary task as per user's choice. The program should give appropriate message if any wrong choice-number is input.
MENU
1. Lateral Surface Area of Cuboid (LSA)
2. Total Surface Area of Cuboid (TSA)
3. volume of Cuboid
4. Length of Longest Diagonal of Cuboid
Enter your choice:
[IF L, B and H are length, breadth and height respectively, then
LSA = 2(L+B)H, TSA = 2(LB+BH+HL), Vol=LBH,
Longest Diagonal = square-root of (L^2 + B^2 + H^2)]
- C program: A program to display the following menu and then do the necessary task as per user's choice. The program should give appropriate message if any wrong choice-number is input.
MENU
1. Area of triangle using base and altitude
2. Area of triangle using three sides
3. Area of triangle using coordinates of three vertices
Enter your choice:
[By method1, Area = 1/2*base*height;
By method2, area = square-root of s(s-a)(s-b)(s-c) where s=(a+b+c)/2
By method3, area = 1/2{x1(y2-y3) + x2(y3-y1) + x3(y1-y2)}]
- C program: A program to display the following menu and then do the necessary task as per user's choice. The program should give appropriate message if any wrong choice-number is input.
MENU
1. Simple Interest
2. Compound Interest
Enter Your choice:
[SI = PRT/100; CI = p{(1+R/100)^T - 1} ]
/*A C Program to accept any integer and display whether it is negative integer or a non-negative integer.*/
#include<stdio.h>
int main()
{
int n;
printf("\nEnter any integer: ");
scanf(“%d”,&n);
if(n<0)
{
printf("%d is negative integer.",n);
}
else
{
printf("%d is a non-negative integer.",n);
}
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*A C Program to accept any persons age as integer and display whether the individual is an Adult or a Minor.*/
#include<stdio.h>
int main()
{
int age;
printf("\nEnter the Age: ");
scanf(“%d”,&age);
if(age>=18)
{
printf(“\nThe person is an adult.”);
}
else
{
  printf(“\nThe person is a MINOR.”)
}
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*A C Program to accept any number and display its absolute value.*/
#include<stdio.h>
int main()
{
float x;
printf("\nEnter any Number: ");
scanf(“%d”,&x);
if(x<0)
x*=(-1); //or x=x*(-1);
printf("Required Absolute value is = %d",x);
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*(IF... ELSE IF..... BLOCK STATEMENT)
A C Program to accept two integers and display the relation between them (i.e. >, < or =).*/
#include<stdio.h>
int main()
{
int x,y;
printf("\nEnter 1st integer: ");
scanf(“%d”,&x);
printf("\nEnter 2nd integer: ");
scanf(“%d”,&y);
if(x>y)
printf("\n%d is the greater of the two.",x);
else if(x<y)
printf("\n%d is the greater of the two.",y);
else
printf(“\nBoth are equal”);
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*(NESTED IF) A C Program to accept three numbers and display the greatest among the three.*/
#include<stdio.h>
int main()
{
float x,y,z;
printf("\nEnter 1st number: ");
scanf(%d”,&x);
  printf("\nEnter 2nd number: ");
scanf(%d”,&y);
printf("\nEnter 3rd number: ");
scanf(%d”,&z);
if(x>y)
{
if(x>z)
{
printf(“\n%d is greatest.”,x);
}
else
{
printf(“\n%d is greatest.”,z);br /> }
}
else
{
if(y>z)
{
printf(“\n%d is greatest.”,y);
}
else
{
printf(“\n%d is greatest.”,z);br /> }
}
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*(NESTED IF) A C Program to accept any year in "yyyy" format and display weather it is a Leap-Year or not.*/
#include<stdio.h>
int main()
{
int year;
printf("\nEnter any year in 'yyyy' format: ");
scanf(“%d”,&year);
if(year%400==0)
{
printf(“\n%d is a Leap Year”,year);
}
else
{
if(year%100==0)
{
printf(“\n%d is NOT Leap Year”,year);
}
else
{
if(year%4==0)
{
printf(“\n%d is a Leap Year”,year);
}
else
{
printf(“\n%d is NOT a Leap Year”,year);
}
}
}
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners /*A C Program to accept Coefficients and constants (a,b,c) of a quadratic equation ax^2+bx+c=0, and then display its roots.
Author: Pradeep Das Gupta
Compiler: GNU GCC Compiler
*/
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,d,x1,x2;
printf("\nEnter Coefficient of x^2 (a)= ");
scanf("%d",&a);
printf("\nEnter Coefficient of x (b)= ");
scanf("%d",&b);
printf("\nEnter the Constant term (c)= ");
scanf("%d",&c);
if(a)
{
d=b*b-4*a*c;
if(d<0)
printf("\nRoots are Imaginary.");
else
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
}
printf("\nRoots are X1 = %d, X2 = %d",x1,x2);
}
else
{
printf("\nError!!! The given data does not correspond to Quadratic Equation.\nCoefficient of x^2 cannot be zero(0)");
};
return 0;
}
C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners | C programming | Computer Programming for Beginners