Question

In: Electrical Engineering

3. Design a digital watch that allows the user to set and display time.

3. Design a digital watch that allows the user to set and display time.

Solutions

Expert Solution

/*C program to set and display time in a digital clock.*/
 
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<time.h>
 
void main()
{
    system("clear");       //to clear the output screen
    int hr=0, min=0, sec=0;
 
    while(1)
    {
           system("clear");
         
        printf("time:/n")
        printf("%d,%d,%d",hr,min,sec);
         
         //increase second
        sec++;                 //means sec=sec+1
            if(sec==60){
            min=min+1;        // post increment operation
            sec=0;
        }
        if(min==60){
            hr=hr+1;
            min=0;
        }
        if(hr==24)
        {
            hr=0;
            min=0;
            sec=0;
        }
         
        sleep(1);//to sleep the display if there is activity(wait for 1 second)
    }
                   //no need of using return as we took returning type void
         getch();    // to hold the output screen
}

Related Solutions

Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters a number, the program should print out the average of the last 3 numbers (or all numbers if 3 or less have been entered). I would like a detailed explanation so that a beginner level Java programmer could understand.
Design a digital circuit for output ‘e’ for the seven segment display for all possible inputs....
Design a digital circuit for output ‘e’ for the seven segment display for all possible inputs. Inputs: ABCD a f b g    e c d A) Derive a truth table B) Design using K-Map technique, a minimum AND-OR gate network for this system. Draw the resulting digital circuit diagram
2. Design a digital circuit, using a decoder, only Nor gates, a 7-segment display, and D...
2. Design a digital circuit, using a decoder, only Nor gates, a 7-segment display, and D Flip Flops, that repeatedly outputs the sequences of characters ‘P’, ‘E’, ‘A’, ‘L’ if x=0 and ‘L’, ‘E’, ‘A’, ‘P’ if x=1 .
A track on PCB is 2cm if the digital design has a rise time of 16ns,...
A track on PCB is 2cm if the digital design has a rise time of 16ns, and the material dielectric is 4, Should this be a transmission line? Yes or no???
Modify the RetirementGoalapplication to display the amount of money the user will have if the user...
Modify the RetirementGoalapplication to display the amount of money the user will have if the user earns 4%interest on the balance every year. In java pls given code. import java.util.Scanner; public class RetirementGoal2 { public static void main (String[] args) { Scanner input = new Scanner(System.in); int years; int saveAmount; int total; final double RATE; // perform interest calculation System.out.print("How many years until retirement? >> "); years = input.nextInt(); while(years <= 0) { System.out.println("Years cannot be 0 or negative"); System.out.print("Please...
Budgeting allows for a company to set parameters for operations during a specific time period. There...
Budgeting allows for a company to set parameters for operations during a specific time period. There are many uses for a budget within a company or department. Provide examples of how a budget might be used in business and how decision making is affected by the use of a budget.
You are required to design a watch tower. The watch tower is circular and has an...
You are required to design a watch tower. The watch tower is circular and has an outer diameter of 1500mm. The tower is built of 2 skins of masonry brick work. The supplier data sheet says that the density of the brickwork is 1900 kg/m3 . The tower has a slab at the top and watchmen sit there. The tower is built on a square concrete slab 2m by 2m. the slab is 300mm thick. It has finishes of 50mm...
Write a program that prompts the user for their first and lastname. Display the first...
Write a program that prompts the user for their first and last name. Display the first initial of their first name and their last name to the user.Ask the user to input a phone number.The program checks which part of Colorado a phone number is from using the values below.If the second digit of the phone number is one of the below digits, print the phone number and which part of Colorado it is from. If none of the digits...
A slot machine is a gambling device which allows a user to insert money and pull a lever (or push a button) and displays a set of random images.
A slot machine is a gambling device which allows a user to insert money and pull a lever (or push a button) and displays a set of random images. Design a Python program which simulates a "free" slot machine which displays a random combination of 3 of the following items (as text): Cherries, Oranges, Plums, Melons, and Bells If none of the items match, the user wins nothing. If only two of the items match, the user wins $5 If all three items...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT