Q.1: Create a Rainbow using C.
Ans.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gdriver = DETECT, gmode;
int x, y, i;
initgraph(&gdriver, &gmode, "C:\\TurboC3\\BGI");
x=getmaxx()/2;
y=getmaxy()/2;
for(i=20; i<250; i++)
{
delay(100);
setcolor(i/10);
arc(x,y, 0, 180, i-10);
}
getch();
}
Q.2: The Cursor in the user screen.
Ans.
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<dos.h>
void main()
{
union REGS i, o;
i.x.ax=1;
int86(0x33, &i, &o);
getch();
}
Q.3: Create Sound with using C language.
Ans.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int count=50;
clrscr();
while(count--)
{
sound(10*random(100);
delay(200);
nosound();
textattr(random(16)+'a'+ BLINK);
cprintf(" sabya ");
}
getch();
}
Q.4: A Login page format By using C.
Ans.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[50], b[50], c[50], g[]="wellcom to you ";
int k;
clrscr();
printf("Enter a user name:>");
gets(a);
printf("Enter the the password:>");
gets(b);
printf("Enter conform password:>");
gets(c);
k=strcmp(c,b);
if(k==0)
{
printf("User is valid \t Plese press enter to continue");
getch();
strcat(g,a);
printf("\n %s",g);
}
else
printf("Invalid input \n Try Again");
getch();
}
Q.5: Shutdown your PC/Computer through the C Program.
Ans.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
char c;
printf("Do you want to shutdown your PC (y/n) : ");
scanf("%c", &c);
if (c == 'y' || c == 'Y')
system("C:\\Windows\\System32\\shutdown /s /t 0");
else
printf("You don't want to shutdown your PC");
getch();
return 0;
}
0 Comments