Question

In: Computer Science

in C a program that counts up from 0 to 20, and reset to 0 after...

in C a program that counts up from 0 to 20, and reset to 0 after 20. needs to count by a press button

Solutions

Expert Solution

Code:

#include <stdio.h>
#include<conio.h>

int main()
{
    int i;
    char ch;
    
    
    for(int i=0;i<=20;i++)
    {
        printf("\ncount = %d",i);
        printf("\nPress enter to count next.\nPress x to quit. ");
        scanf("%c",&ch);
        if(ch=='x')
            break;
        if(i==20)
            i=-1;
        printf("%c",ch);
        
    }
        
        
    

    return 0;
}

Output:


Related Solutions

write the following C program that ccepts command-line arguments following argv[0] — up to 20 decimal...
write the following C program that ccepts command-line arguments following argv[0] — up to 20 decimal integer literals. Each of these decimal integer literals will be expressed using decimal digits, only, and none of the decimal integer literals will be prefixed by a plus or minus sign. None of the decimal integer literals will be greater than ULONG_MAX. The program prints the integers in order, least-to-greates and also prints the sum of the integers.
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Create a program in C that counts the number of characters in a word when a...
Create a program in C that counts the number of characters in a word when a user inputs a string. Use stdin to read an input string. For example, if a user inputs: “The dog is good” the output should be a= [The], b=3 a= [dog], b=3 a= [ is], b=2 a= [good], b=4 a= [ ], b=0000 Take into account EOF. If an EOF is reached at the end of the string then the output should be 0000. (example...
Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset()...
Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset() that works for both chips to reset a program.
Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset()...
Atmega128 and Pic24e have the reset interrupt at the program address 0x0. Write a function reset() that works for both chips to reset a program.
Write a C program that prompts the user to enter some information about up to 20...
Write a C program that prompts the user to enter some information about up to 20 individuals (think of a way to welcome and prompt the user). It must be stored in a structure. Once data is entered, the program output it as shown in sample run below. Your program should include a structure with a tag name of: “information”. It should contain the following data as members: a struct to store employee's name, defined as: struct name fullname e.g....
Write a C program that counts the number of repeated characters in a phrase entered by...
Write a C program that counts the number of repeated characters in a phrase entered by the user and prints them. If none of the characters are repeated, then print “No character is repeated” For example: If the phrase is “full proof” then the output will be Number of characters repeated: 3 Characters repeated: f, l, o Note: Assume the length of the string is 10. ###Note: the output should print exactly as it is stated in the example if...
In a machine that temperature changes from 20 ∘C∘C up to 120 ∘C∘C a tungsten wire...
In a machine that temperature changes from 20 ∘C∘C up to 120 ∘C∘C a tungsten wire filament 15.0 cmcm  long with a diameter of 1.30 mmmm  will be used. The wire will carry  14.0 AA   at all temperatures ( Resistivity of tungsten at 20 ∘C∘C is 5.25×10−8Ω⋅m5.25×10−8Ω⋅m , the temperature coefficient of resistivity at 20 ∘C∘C is 0.0045 ∘C−1∘C−1 ) Calculate the maximum electric field in this filament? Calculate the resistance of the filament  with that field? Calculate the maximum potential drop over the...
In a machine that temperature changes from 20 ∘C up to 120 ∘C a tungsten wire...
In a machine that temperature changes from 20 ∘C up to 120 ∘C a tungsten wire filament 13.0 cm long with a diameter of 1.20 mm will be used. The wire will carry  11.0 A at all temperatures ( Resistivity of tungsten at 20 ∘C is 5.25×10^−8Ω⋅m , the temperature coefficient of resistivity at 20 ∘C is 0.0045 ∘C^−1 ). A-)Calculate the maximum electric field in this filament? B-)Calculate the resistance of the filament  with that field? C-)Calculate the maximum potential drop...
I need a C++ program using while loops that counts the number of characters in a...
I need a C++ program using while loops that counts the number of characters in a sentence. The user inputs a sentence and then terminates the input with either '.' or '!'. And then it needs to count and display the number of a's, e's, i's, o's, u's, and consonants. The program should read both lower and upper case. They don't want us using switch statements or string operators, and want us to us if else if statements. I have...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT