c and c++ tutorials // online learning spot
Problem 1. Make a program to print your name on screen and program closes after you press any key.
#include<stdio.h>
#include<conio.h>
main()
{
printf("Your name");
getch();
}
The getch() written at the last will not get execute till you not press any key.
As you press key, work of getch() got over and there is no further work to do so program ends automatically.
Problem 2. Make a program which at start First clears the screen and then prints your name on screen.
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("Your name");
}
First work in your list is clrscr() here so first console will be cleared then you name will be printed.
Problem 3. Make a program that displays your name 2 seconds your program starts.
#include<stdio.h>
#include<dos.h>
main()
{
delay(2000);
printf("Your name");
}
Problem 1. Make a program to print your name on screen and program closes after you press any key.
#include<stdio.h>
#include<conio.h>
main()
{
printf("Your name");
getch();
}
The getch() written at the last will not get execute till you not press any key.
As you press key, work of getch() got over and there is no further work to do so program ends automatically.
Problem 2. Make a program which at start First clears the screen and then prints your name on screen.
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("Your name");
}
First work in your list is clrscr() here so first console will be cleared then you name will be printed.
Problem 3. Make a program that displays your name 2 seconds your program starts.
#include<dos.h>
main()
{
delay(2000);
printf("Your name");
}
You can see, time is provided inside the parentheses. It is in milli-seconds and no need to specify unit.
No comments:
Post a Comment