Professional Documents
Culture Documents
Aim:
Write a C program to check whether the given two numbers are equal or not.
Algorithm:
Step1: Start
Step2: Read two numbers
Step3: if (a==b) then
Step4: Print Given numbers are equal
Step5: else Print Given numbers are not equal
Step6: Stop
Result:
Thus the program has been executed successfully.
Algorithm:
Step1: Start
Step 2: Enter Customer name
Step 3: Read no. of units
Step 4: Calculate
if (unit<=100)
amount=units*4;
else if (units>100 && units<=300)
amount=units*4.5;
else if (units>300 && units<=500)
amount=units*4.75;
else
amount=units*5;
Step 5: Print customer name and amount
Step 6: Stop
Electricity Bill:
Name: John
Amount: Rs.1125
Result:
Thus the program has been executed successfully.
C program to check the number is positive/negative odd or even (using Nested if)
Aim:
Write a C program to check whether the given number is positive/negative odd or even.
Algorithm:
Step 1: Start
Step 2: Read a number
Step 3: If(a>0) then
Step 4: If(a%2==0) then
Step 5: Print the given number is positive even
Step 6: Else Print the given number is positive odd
Step7: Else
Step 8: If(a%2==0) then
Step 9: Print the given number is negative even
Step10: Else Print the given number is negative odd
Step11: Stop
Result:
Thus the program has been executed successfully.
Algorithm:
Step1: Start
Step 2: Read no. of seconds
Step 3: Print Seconds into
1.Minutes
2. hours
3.days
Step 4: read any choice
Step 5: calculate
switch(ch)
{
case 1:
mins= seconds / 60;
printf(minutes:%d,mins);
break;
case 2:
hrs = seconds / (60*60);
printf(hours:%d,hrs);
break;
case 3:
days = seconds / (24*60*60);
printf(days:%d,days);
break;
default: print pls try again
Step 6: Stop
Minutes: 205
Result:
Thus the program has been executed successfully.
Algorithm:
Step1: Start
Step 2: Enter a number
Step 3:
rev=0, t=n;
while(t!=0)
{
rem=t%10;
rev=rev*10+rem;
t/=10;
}
/* Checking if number entered by user and it's reverse number is equal. */
if(rev==n)
printf("%d is a palindrome.",n);
else
printf("%d is not a palindrome.",n);
Step 4: stop
Result:
Thus the program has been executed successfully.