Professional Documents
Culture Documents
ALGORITHM:
#include<stdio.h>
#include<conio.h>
int main()
{
float session_ended_timing;
float session_started_timing = 10.00;
float session_continued_timing = 01.20;
session_ended_timing = session_started_timing + session_continued_timing;
printf("session_ended_timing %f",session_ended_timing);
}
2.A man spent 756 days in a forest and how many years or week days he was in forest.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int days = 756;
int years, weeks;
printf("\nthe no of days in forest is 756");
years= days / 365 ;
printf("\nNumber of years is:\n %d",years);
weeks = (days - (years * 365)) / 7;
printf("\nNumber of weeks is:\n %d",weeks);
}
3.I have 1756 amount in my hand I need the denominatorbased on 500,100,50,5,1.
ALGORITHM
#include <stdio.h>
#include<conio.h>
int main()
{
int amount;
int note500, note100, note50, note20, note10, note5, note2, note1;
note500 = note100 = note50 = note20 = note10 = note5 = note2 = note1 = 0;
printf("Enter amount: ");
scanf("%d", &amount);
if(amount >= 500)
{
note500 = amount/500;
amount -= note500 * 500;
}
if(amount >= 100)
{
note100 = amount/100;
amount -= note100 * 100;
}
if(amount >= 50)
{
note50 = amount/50;
amount -= note50 * 50;
}
if(amount >= 5)
{
note5 = amount/5;
amount -= note5 * 5;
}
if(amount >= 1)
{
note1 = amount;
}
printf("Total number of notes = \n");
printf("500 = %d\n", note500);
printf("100 = %d\n", note100);
printf("50 = %d\n", note50);
printf("5 = %d\n", note5);
printf("1 = %d\n", note1);
return 0;
}
4.Given duration in minutes convert to the seconds.
2 minutes.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
int main()
{
int minutes,seconds;
printf("\n the minutes to convert into second\t");
scanf("%d",&minutes);
seconds = minutes * 60;
printf("\n the minutes that converted into second\t %d",seconds);
}
5.Given duration in seconds convert to the hour and minutes.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
int main()
{
int minutes,seconds,hours;
printf("\n the seconds to convert into minutes and hour\t");
scanf("%d",&seconds);
hours = (seconds/3600);
minutes = (seconds -(3600*hours))/60;
seconds = (seconds -(3600*hours)-(minutes*60));
printf("\n the seconds that converted into minutes\t %d",minutes);
printf("\n the seconds that converted into hours\t %d",hours);
}
6.Given duration in minutes to hours?
ALGORITHM:
#include<stdio.h>
int main()
{
int minutes,hours;
printf("\n Enter minutes = ");
scanf("%d",&minutes);
hours = (minutes/60);
printf("\n Minutes to hour = %d hours ",hours);
}
7.2 digit extraction.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,left,right;
printf("\n enter the value of n:");
scanf("%d",&n);
left =n/10;
right = n%10;
printf("\n the left digit of 2 digit number is %d",left);
printf("\n the right digit of 2 digit number is %d",right);
}
8.2digit reverse.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,left,right,reverse;
printf("\n enter the value of n:");
scanf("%d",&n);
left =n/10;
right = n%10;
reverse = right * 10 + left;
printf("\n the left digit of 2 digit number is %d",left);
printf("\n the right digit of 2 digit number is %d",right);
printf("\n the reverse value of 2 digit number is %d",reverse);
}
9.3 digit extraction.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,temp,factor = 1;
printf("\n enter a number:");
scanf("%d",&number);
temp = number;
while(temp)
{
temp =temp/10;
factor = factor*10;
}
printf("\n enter the digits of the given number:");
while(factor,1)
{
factor = factor/10;
printf("%d",number/factor);
number =number%factor ;
}
}
10.3 digit reverse.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,left,middle,right,temp,reverse;
printf("\n enter the three digit number:");
scanf("%d",&number);
left = number/100;
temp = number%100;
middle = temp/10;
right = temp%10;
reverse = right * 100 +middle * 10 +left;
printf("\n the reverse of the number is: %d",reverse);
}
11. 4 digit extraction.
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,middle1,middle2,left,right,temp1,temp2;
printf("\n enter the 4 digit etraction number :");
scanf("%d",&number);
left = number / 1000;
temp1= number % 1000;
middle1 = temp1 / 100;
temp2 = temp1%100;
middle2 = temp2 /10;
right = temp2%10;
printf("\n the left value of 4 digit etraction number %d:",left);
printf("\n the right value of 4 digit etraction number %d:",right);
printf("\n the middle 1 middle 2 value of 4 digit etraction number %d , %d:",middle1,middle2);
printf("\n the temp 1 temp 2 value of 4 digit etraction number %d , %d:",temp1,temp2);
}
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,left,Lmiddle,Rmiddle,right,temp1,temp2,reverse;
printf("\n enter the three digit number:");
scanf("%d",&number);
left = number/1000;
temp1 = number %1000;
Lmiddle = temp1/100;
temp2 = temp1%100;
Rmiddle = temp2/10;
right = temp2%10;
reverse = right * 1000 +Rmiddle * 100 + Lmiddle *10 + left;
printf("\n the reverse of the number is: %d",reverse);
}
ALGORITHM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,value;
printf("\n enter the number:");
scanf("%d",&number);
value = number %10;
printf("\n the unit digit value is %d",value);
}