You are on page 1of 15

1.A session staqrted at 10 am and continued for 80 minutesthen when will the session end.?

ALGORITHM:

 include the library files


 invoking main function
 declare the variables
 calculate the session ended timing using formula.
 session_ended_timing = session_started_timing + session_continued_timing
 disply the value calculated.

#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 the library files


 invoking main function
 declare the variables
 print the number of days in the forest
 calculate the number of year using formula.
 print the number of years in the forest
 calculate the number of weeks using formula.
 Print the number of weeks in the forest.
 session_ended_timing = session_started_timing + session_continued_timing
 display the value calculated.

#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 the library functions


 invoke main functions
 declare the variables
 print the amount
 input the amount as integer
 using if function check if the amount is equal to or greater than 500 then
 calculate the number of 500 rupees note
 using if function check if the amount is equal to or greater than 100 then
 calculate the number of 100 rupees note
 using if function check if the amount is equal to or greater than 50 then
 calculate the number of 50 rupees note
 using if function check if the amount is equal to or greater than 5 then
 calculate the number of 5 rupees note
 using if function check if the amount is equal to or greater than 1 then
 calculate the number of 1 rupees note
 print the denomination values.

#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 the header files


 invoke the main functions
 initialize the variable.
 Print the minutes value
 calculate into the seconds using formula.
 Display the converted value

#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 the header files


 invoke the main functions
 initialize the variable.
 Print the seconds value
 calculate into the minutes using formula.
 Display the converted value

#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 the header files


 invoke the main functions
 initialize the variable.
 Print the minutes value
 calculate into the hours using formula.
 Display the converted value

#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 the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the left right using formula.
 Display the the values

#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 the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the left right and reverse using formula.
 Display the the values

#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 the header files


 invoke the main functions
 initialize the variables
 set the temp value as number
 using while function calculate the factor and temp value.
 Display the digits of the given number.
 Using while function for factor calculate the factor value and number.
 Display the the values

#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 the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the left right reverse and middle using formula.
 Display the values

#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 the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the left right middle1 middle2 temp 2 and temp1 using formula.
 Display the values

#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);
}

12. 4 digit reverse.

ALGORITHM:

 include the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the left,Lmidlle,Rmiddle,temp1,temp2 right and reverse using formula.
 Display the values

#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);
}

13.Extract the unit digit for given n digit number.

ALGORITHM:

 include the header files


 invoke the main functions
 initialize the variables
 input the number from the user
 calculate the value using formula.
 Display the unit digit value

#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);
}

You might also like