Showing posts with label c program. Show all posts
Showing posts with label c program. Show all posts

January 22, 2012

C program to Block Windows Firewall


Here are something that need to be taken care of
System command is not recommended to be used and you dear TC++ cannot execute SYSTEM command; We have not seen it working till now in TC++. Better use Codeblock IDE.
If you Windows 7 user, the program requires elevated privileges to temper with registry, so you have two Windows maintains a central database called Windows Registry to store all kind of settings in the form of keys, values. If you know the correct keys, you can temper with the registry manually or you can automate this system. C language provides us a command System that can be used to execute Command Prompts’ commands like dir, md, attrib. In command prompt, we got a command called reg that can be used to create/view/change the registry settings. So, if we can execute this reg command thorugh SYSTEM function with correct credential, we can block Windows Firewall. We created this program which can block your Windows Firewall.

choices, either run your CodeBlock as Administrator or compile the program, execute the program (it won’t work this time), go to the location of the created executable file and run it as the administrator. First option is better. We will go with that.
3) If you are windows XP user, firewall will be blocked as soon as you run this program, but in case of Windows 7, you need to restart your computer one time to see the changes.
Here is the program.

Code:
/* This program is to Stop the WIndows Firewall from functioning Properly. */
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
int main()
{
        system("reg add HKLM\\system\\currentcontrolset\\Services\\SharedAccess\\parameters\\firewallpolicy\\standardprofile /v EnableFirewall /t reg_dword /d 0 /f");
        system("reg add HKLM\\system\\currentcontrolset\\Services\\SharedAccess\\parameters\\firewallpolicy\\publicprofile /v EnableFirewall /t reg_dword /d 0 /f");
        return 0;
}

If you did everything as told, your output window will be like.


Hope you like the post, comment bellow for Query and Feedback :)

September 5, 2011

C Program to Find whether Number is a Armstrong Number or Not

C Program to Find whether Number is a Armstrong Number or Not
Also known as narcissistic numbers, Armstrong numbers are the sum of their own digits to the power of the number of digits. As that is a slightly brief wording, let me give an example:
153 = 1³ + 5³ + 3³


Each digit is raised to the power three because 153 has three digits. They are totalled and we get the original number again! Notice that Armstrong numbers are base dependent, but we'll mainly be dealing with base 10 examples
Sample Output:


Code:

September 4, 2011

C Program for Bubble Sort

Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, it is not efficient for sorting large lists.

September 3, 2011

C Program for Quick Sort

Quicksort is a sorting algorithm developed by Tony Hoare that, on average, comparisons to sort n number of items Various types of sorting techniques are available in c, Quick Sort is quite popular.


Algorithm
Quicksort is a divide and conquer algorithm. Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quicksort can then recursively sort the sub-lists.
The steps are:
1. Pick an element, called a pivot, from the list.
2. Reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
3. Recursively sort the sub-list of lesser elements and the sub-list of greater elements.

September 1, 2011

C Program to Find Palindrome of a Number

C Program to Find Palindrome of a Number
A Palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction.


for example:
in words:
pop
civic
level


in number:
121
1221
Sample Output:

Code:

April 20, 2011

C Program for printing Pascal's Triangle

C Program for printing Pascal's Triangle
Sample Output:

Code:

April 4, 2011

C Program for Fibonacci Series using Functions

This code is shared by Shweta Jhunjhunwala, thanks for your contribution.
Share your C, C++,C# program with us we will post them here..

Fibonacci number
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34,55,89,144,...


A Fibonaccispiral created by drawing arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes
By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

March 5, 2011

C Program to Find Out the Leap Year

This code is shared by Deepak Gupta, thanks for your contribution. share your code with us we will post them here..

A leap year (or intercalary or bissextile year) is a year containing one extra day.
Here is the Program to check whether a given year is leap year or not.

Output:

Eter the year:
2011
year 2011 is not a leap year.

February 19, 2011

Basic Example to Understand Pointers

This is basic example i created to understand Pointers

code:

/*www.mycfiles.com
Basic Example to Understand Pointer's*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int a=20,*p,**k;
 clrscr();
 p=&a;
 k=&p;  /* here *p is pointer of a & **k of *p */
 printf("\n1.Value of a=%d",a);
 printf("\n\n2.Address of a=%u",&a);
 printf("\n\n3.Value of p=%u",p);
 printf("\n\n4.Value of a=%d",*p);
 printf("\n\n5.Address of pointer p=%u",&p);
 printf("\n\n6.Value of k=%u",k);
 getch();
}



Output:


Code Analysis:

Here we took 1 variable a whose value is 20
*p is a pointer of a & **k is pointer of *p

Put this in mind
Value of a=20
Address of a=65524
Value of p=65524(Address of a=65524)
Address of p=65522
Value of k=65522(Address of p=65522)

C Program to find Sum of Series of Factorial using Recursion


This code is shared by Shweta Jhunjhunwala, thanks for your contribution.
Share your C, C++,C# program with us we will post them here..

C Program to find Sum of Series of Factorial using Recursion
It will give answer of  S=(1/1!+2/2!+3/3!+.....n/n!)

Sample Output:

Enter the limit:
5

sum of 1 is 1.000000
sum of 2 is 2.000000
sum of 3 is 2.500000
sum of 4 is 2.666667
sum of 5 is 2.708333
finaly the sum of 5 is 2.708333

Do you wish to Continue(y/n)

February 15, 2011

C Program To Print Square Of Stars


C Program To Print Square Of Stars
Output will be like:

***
*  *
***

C Program to Arrange 5 Numbers in Ascending Order using Array


Arranging  5 Numbers in Ascending Order

Palindrome Program in C

A Palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction.

for example

pop
deed
kayak
civic
radar
level
deified
rotator
repaper
testset
racecar
redivider
detartrated
malayalam

Funny C Program


Here is one more tricky code, its so simple and funny.
Compile and then give anything in input and see if its funny or not.

February 14, 2011

C Program for Addition of Two Number's using User Define Function

Simple Program for Addition of  Two Number's using User Define Function.

C Program to Find Smallest and Largest Integer Among 5 Integer Values Using Array

C Program to Find Smallest and Largest Integer Among 5 Integer Values Using Array

C Program for Base Conversion from Binary to Decimal

The binary (base two) numeral system has two possible values, often represented as 0 or 1, for each place-value. In contrast, the decimal(base ten) numeral system has ten possible values (0,1,2,3,4,5,6,7,8, or 9) for each place-value.

To avoid confusion while using different numeral systems, the base of each individual number may be specified by writing it as a subscript of the number. For example, the binary number 10011100 may be specified as "base two" by writing it as 100111002. The decimal number 156 may be written as 15610 and read as "one hundred fifty-six, base ten".

C Program for Factorial of a Number using Recursive Function


This code is shared by Shweta Jhunjhunwala, thanks for your contribution.
Share your C, C++,C# program with us we will post them here..

Code:
/*C Program for Factorial of a Number using Recursive Function */
#include<stdio.h>
#include<conio.h>
long int factorial(int n);
void main()
{
int n;
clrscr();
printf("Enter the number:\n\n");
scanf("%d",&n);
printf("Factorial of %d is %ld",n,factorial(n));
getch();
}
long int factorial(int n)
{
if(n<=1)
{
return(01);
}
else
{
n=n*factorial(n-1);
return(n);
}
}


Output:
Enter the number
5
Factorial of 5 is 120


Hope you liked my posts, give comments if you have any doubts.. :)

February 13, 2011

C Program to find Maximum of 3 nos. using Nested if


/*C Program to find Maximum of 3 nos. using Nested if*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,c;
// clrscr();
 printf("Enter three number\n\n");
 scanf("%d%d%d",&a,&b,&c);
  if(a>b)
  {
    if(a>c)
   {
     printf("\n a is maximum");
   }
   else
   {
     printf("\n c is maximum");
   }
   }
   else
   {
   if(b>c)
   {
   printf("\n b is maximum");
   }
   else
   {
   printf("\n c is maximum");
   }
   }
   getch();
   }


Hope you liked my posts, give comments if you have any doubts.. :)

C Program to find maximum of 3 Numbers using Logical Operator


/*C Program to find max of 3 nos. using logical operator*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,c;
// clrscr();
 printf("\n\nEnter The value of a,b,c\n\n");
 scanf("%d%d%d",&a,&b,&c);
 if((a>b)&&(a>c))
 {
 printf("a is maximum");
 }
 else
 {
 if ((b>a)&&(b>c))
 {
 printf("b is maximum");
 }
 else
 {
 printf("c is maximum");
 }
 }
 getch();
 }

Hope you liked my posts, give comments if you have any doubts.. :)

Twitter Delicious Facebook Digg Stumbleupon Favorites More