#include <stdio.h>
int main() {
system("shutdown -P now");
return 0;
}
Hay friends .. AREA OF LANGUAGE IS TOO WIDE BUT NOW APPROXIMATE THEORY AND "C PROGRAMING CODES" ARE AVAILABLE . GOPAL KRISHNA "CHAUHAN"
Friday, 21 September 2012
C programming code for Ubuntu Linux
C programming code for Windows 7
#include <stdio.h>
#include <stdlib.h>
main()
{
char ch;
printf("Do you want to shutdown your computer now (y/n)\n");
scanf("%c",&ch);
if (ch == 'y' || ch == 'Y')
system("C:\\WINDOWS\\System32\\shutdown /s");
return 0;
}
C program to shutdown or turn off computer
If you are using Turbo C Compiler then execute
your file from folder. Press F9 to build your executable file from
source program. When you run from within the compiler by pressing
Ctrl+F9 it may not work.
C programming code for Windows XP
#include <stdio.h>
#include <stdlib.h>
main()
{
char ch;
printf("Do you want to shutdown your computer now (y/n)\n");
scanf("%c",&ch);
if (ch == 'y' || ch == 'Y')
system("C:\\WINDOWS\\System32\\shutdown -s");
return 0;
}
c program to get ip address
C programming code
#include<stdlib.h>
main()
{
system("C:\\Windows\\System32\\ipconfig");
system("pause");
return 0;
}
c program to print date
C programming code
#include<stdio.h>
#include<conio.h>
#include<dos.h>
main()
{
struct date d;
getdate(&d);
printf("Current system date is %d/%d/%d",d.da_day,d.da_mon,d.da_year);
getch();
return 0;
}
c program to add two complex numbers
C programming code
#include <stdio.h>
struct complex
{
int real, img;
};
main()
{
struct complex a, b, c;
printf("Enter a and b where a + ib is the first complex number.\n");
printf("a = ");
scanf("%d", &a.real);
printf("b = ");
scanf("%d", &a.img);
printf("Enter c and d where c + id is the second complex number.\n");
printf("c = ");
scanf("%d", &b.real);
printf("d = ");
scanf("%d", &b.img);
c.real = a.real + b.real;
c.img = a.img + b.img;
if ( c.img >= 0 )
printf("Sum of two complex numbers = %d + %di\n",c.real,c.img);
else
printf("Sum of two complex numbers = %d %di\n",c.real,c.img);
return 0;
}
C programming code using random function(Turbo C compiler only)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int n, max, num, c;
printf("Enter the number of random numbers you want ");
scanf("%d",&n);
printf("Enter the maximum value of random number ");
scanf("%d",&max);
printf("%d random numbers from 0 to %d are :-\n",n,max);
randomize();
for ( c = 1 ; c <= n ; c++ )
{
num = random(max);
printf("%d\n",num);
}
getch();
return 0;
}
Subscribe to:
Posts (Atom)