C
Programming and Technical
Programming
Technical
1. Write a program that lets you enter a number of hours, and that converts it to days and hours. For example, 111 hours = 4 days and 15 hours. You can write separate subroutines to calculate the days and hours, or just do the calculations in the main program.
2.
Write a program that prints the largest of the 5 numbers that you entered. Write the appropriate kind of loop which will cause the user to enter 5 numbers, then have an “if statement” inside the loop which checks each new number against the current max value. When initializing the max number, make it be something very small, so that the first number entered by the user is guaranteed to be the new max.
Read Solution (Total 7)
-
- 1.#include
#include
int main(void)
{
int days,hours,h;
clrscr();
printf("
ENTER HOURS WHICH YOU WANT TO CONVERT IN DAYS AND HOURS: ");
scanf("%d",&h);
days=h/24;
hours=h%24;
printf("
%d hours = %d days + %d hours",h,days,hours);
getch();
return 0;
}
output:
ENTER HOURS WHICH YOU WANT TO CONVERT IN DAYS AND HOURS :111
111 hours = 4 days + 15 hours
2.#include
#include
int main(void)
{
int max=0,i,n,a[20];
clrscr();
printf("
ENTER THE NO. OF ELEMENTS YOU WANT TO ENTERED:");
scanf("%d",&n);
printf("
ENTER THE VALUE OF THOSE ELEMENTS");
for(i=0;i - 10 years agoHelpfull: Yes(7) No(0)
- 2..#include
#include
int main(void)
{
int max=0,i,n,a[20];
clrscr();
printf("ENTER THE NO. OF ELEMENTS YOU WANT TO ENTERED:");
scanf("%d",&n);
printf("ENTER THE VALUE OF THOSE ELEMENTS");
for(i=0;i - 10 years agoHelpfull: Yes(0) No(0)
- # include
void main()
{
int a=2,b=6;//example taken values of a,b;
int j=0;
while(j - 10 years agoHelpfull: Yes(0) No(0)
- #include
#include
void main()
{
int hour, day, rem;
printf("Enter hours: ");
scanf("%d",&hour);
rem=hour%24;
day = hour/24;
printf("%d hour = %d days and %d hours",hour,day,rem);
getch();
} - 10 years agoHelpfull: Yes(0) No(0)
- 2. class Program {
static void Main(string[] args) {
Single a,maxNum = 0;
for(i=0;imaxNum){
maxNum = a;
}
}
Console.WriteLine("Maximum of 5 numbers entered is: "+maxNum);
Console.ReadLine();
}
} - 10 years agoHelpfull: Yes(0) No(0)
- #include
#include
void main()
{
int i,a[5],max=0;
for(i=0;i - 9 years agoHelpfull: Yes(0) No(0)
- #include
int main()
{
int h[5],i,m=0;
for(i=0;i - 9 years agoHelpfull: Yes(0) No(0)
C Other Question