Question

Write two C++ programs. 1, When we write a message then this message blinking out the...

Write two C++ programs.
1, When we write a message then this message blinking out the screen.
2, When we write a message then the message scrolling out the screen.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer for 1:

#include <iostream>
#include <conio.h> 
#include <windows.h>
 using namespace std;
 int main(int argc, char** argv)
 {
   int x,y,i;char name[10];
   textcolor(10);
   x=wherex();y=wherey();       //corrdinates of caret will be stored in x & y.
   cout<<"\t\t\t\tWelcome\n";
   textcolor(15);
   cout<<"\nEnter your name\n";
   gets(name);
   while(1)
   {
      for(i=10;i<15;i++)
      {
         textcolor(i);
         gotoxy(x,y);          //Transferring caret to the coordinates stored in x & y.
         cout<<"\t\t\t\tWelcome";
         Sleep(300);
      }
   }
   return 0;
 }

Answer for 2:

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

HANDLE hStdout;

int ScrollByAbsoluteCoord(int iRows)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
SMALL_RECT srctWindow;

// Get the current screen buffer size and window position.

if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
{
printf("GetConsoleScreenBufferInfo (%d)\n", GetLastError());
return 0;
}

// Set srctWindow to the current window size and location.

srctWindow = csbiInfo.srWindow;

// Check whether the window is too close to the screen buffer top

if ( srctWindow.Top >= iRows )
{
srctWindow.Top -= (SHORT)iRows; // move top up
srctWindow.Bottom -= (SHORT)iRows; // move bottom up

if (! SetConsoleWindowInfo(
hStdout, // screen buffer handle
TRUE, // absolute coordinates
&srctWindow)) // specifies new location
{
printf("SetConsoleWindowInfo (%d)\n", GetLastError());
return 0;
}
return iRows;
}
else
{
printf("\nCannot scroll; the window is too close to the top.\n");
return 0;
}
}

int ScrollByRelativeCoord(int iRows)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
SMALL_RECT srctWindow;

// Get the current screen buffer window position.

if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
{
printf("GetConsoleScreenBufferInfo (%d)\n", GetLastError());
return 0;
}

// Check whether the window is too close to the screen buffer top

if (csbiInfo.srWindow.Top >= iRows)
{
srctWindow.Top =- (SHORT)iRows; // move top up
srctWindow.Bottom =- (SHORT)iRows; // move bottom up
srctWindow.Left = 0; // no change
srctWindow.Right = 0; // no change

if (! SetConsoleWindowInfo(
hStdout, // screen buffer handle
FALSE, // relative coordinates
&srctWindow)) // specifies new location
{
printf("SetConsoleWindowInfo (%d)\n", GetLastError());
return 0;
}
return iRows;
}
else
{
printf("\nCannot scroll; the window is too close to the top.\n");
return 0;
}
}

int main( void )
{
int i;

printf("\nPrinting twenty lines, then scrolling up five lines.\n");
printf("Press any key to scroll up ten lines; ");
printf("then press another key to stop the demo.\n");
for(i=0; i<=20; i++)
printf("%d\n", i);

hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

if(ScrollByAbsoluteCoord(5))
_getch();
else return 0;

if(ScrollByRelativeCoord(10))
_getch();
else return 0;
}

Thanks

Add a comment
Know the answer?
Add Answer to:
Write two C++ programs. 1, When we write a message then this message blinking out the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MAC 102 Quiz 2 Write a C++ programs to: 1. (2 points) receive two numbers from...

    MAC 102 Quiz 2 Write a C++ programs to: 1. (2 points) receive two numbers from the keyboard, 2. (3 points) save these two numbers in an array of two elements, 3. (3 points) use a function to swap them, 4. (2 points) display the contents of the array (swapped) on the screen with proper message. You need to email your program to [email protected] no later than 3 pm. Please include your name, quiz #2, MAC102 in the email's subject...

  • 1. Design a blinking LED with two speeds - slow and fast. (BASYS 3) (IN VIVADO)...

    1. Design a blinking LED with two speeds - slow and fast. (BASYS 3) (IN VIVADO) Specification To change from slow to fast press Button 1 and fast to slow press Button 2. Reset puts the machine to slow blinking. entity blink is port (b1, b2, ck, reset: in std_logic; z: out std_logic); end blink;

  • arduino : write a function that print out on the lcd screen the following message hello...

    arduino : write a function that print out on the lcd screen the following message hello world please use function

  • //Done in C please! //Any help appreciated! Write two programs to write and read from file...

    //Done in C please! //Any help appreciated! Write two programs to write and read from file the age and first and last names of people. The programs should work as follows: 1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0, the...

  • requirements write c++ code for the above programs use only 1D arrays with loops and if...

    requirements write c++ code for the above programs use only 1D arrays with loops and if else statement don't use any other way as it would be useful Answer all four parts with comments for better understanding A top-secret message containing letters from A-Z is encoded to numbers using the following mapping: A -> 1 B- 2 Z-> 26 You are a SPY. You have to determine the total number of ways that message can be decoded. Note: An empty...

  • Write in Java! Do NOT write two different programs for Deck and Card, it should be...

    Write in Java! Do NOT write two different programs for Deck and Card, it should be only one program not 2 separate ones!!!!!! The Learning Goal for this exercise is to use and understand and know the difference between arrays and array lists. !!!!Use at least one array defined in your code and two array lists defined by the operation of your code!!!! The array should be 52 elements and contain a representation of a standard deck of cards, in...

  • Write in C: 1.) Write an if/else statement that adds 1 to the variable minors if...

    Write in C: 1.) Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 through 64, and adds 1 to the variable seniors if age is 65 or older. 2.) Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message "player1 wins" is printed to standard out. When score2...

  • Using a Python environment, complete two small Python programs - Write a function which repeatedly reads...

    Using a Python environment, complete two small Python programs - Write a function which repeatedly reads numbers until the user enters “done” Once “done” is entered, print out the sum, average, maximum, and minimum of the values entered If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. 2. Write another function so that it draws a sideways tree pointing right; for example,...

  • Write C programs for the following: 1. Modify the sorting program you wrote in Lab 2...

    Write C programs for the following: 1. Modify the sorting program you wrote in Lab 2 so that it is modular. Write a function called sort that accepts an integer array, sorts it, and returns the sorted array to the main function. Call this function from the main program. In addition, write a subroutine called print_array that accepts an integer array and prints it out in this format: The array is [01 2 3456 7 8 9] Use this function...

  • USE C++ 1. Write a cout statement that displays the message All for one and one...

    USE C++ 1. Write a cout statement that displays the message All for one and one for all! Use an endl stream manipulator to produce a newline at the end of the message. 2. Write a cout statement that displays the message All for one and one for all! Use the \n escape sequence to produce a newline at the end of the message.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT