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

Write the code (in a function) that allows the user to display the first “nb” of...
Write the code (in a function) that allows the user to display the first “nb” of elements in the Fibonacci sequence (each value on a separate line in the console). The order of the Fibonacci sequence goes as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 and on to infinity. Each number is the sum of the previous two (with the 2 starting numbers being 1 and 1). This series of numbers is known as...
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
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
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.
Using Pseudocode: Design a program that allows the user to enter 20 names into a String...
Using Pseudocode: Design a program that allows the user to enter 20 names into a String array. Sort the array in ascending (alphabetical) order and display its contents.
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???
Design a clock display to show the time in hours, minutes, and seconds. Assume that we...
Design a clock display to show the time in hours, minutes, and seconds. Assume that we have a clock of exactly 1 KHz (1000 clock pulses per second). It will use 6 seven-segment displays and operate either in military time (hours 00 to 23) or regular time (1 to 12, with AM and PM). An input line, x, differentiates between the two. A seventh display is used to show A or P in the latter case; it is blank otherwise....
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.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT