C Program:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
#include<stdio.h>
void main()
{
int a,b,sum;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
sum = a + ~b + 1;
printf("Difference of two integers: %d",sum);
}
#include<stdio.h>
#include<conio.h>
void main()
{
#include<stdio.h>
void main()
{
#include<stdio.h>
void main()
{
int x,y,temp;
printf("Enter the value of xand y\n");
scanf("%d%d", &x, &y);
printf("Before Swapping\n x= %d\n y = %d\n",x,y);
temp = x;
x= y;
y = temp;
printf("After Swapping\n x= %d\ny= %d\n",x,y);
}
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char a[100],b[100];
printf("Enter the string to check if palindrome or not\n");
gets(a);
strcpy(b,a);
strrev(b);
if(strcmp(a,b)==0)
printf("\nEntered string is palindrome");
else
printf("\nEntered string is not palindrome");
getch();
}
#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int len,i;
char a[100];
printf("Enter the string to check whether it is palindrome or not\n");
gets(a);
len=strlen(a);
for(i=0;i<len/2;i++)
{
if(a[i]!=a[len-i-1])
break;
}
if(i==len/2)
printf("\nEntered string is palindrome");
else
printf("\nEntered string is not palindrome");
getch();
}
#include<stdio.h>
void main()
{
int n;
printf("Enter an integer\n");
scanf("%d",&n);
if ( n%2 == 0 )
printf("Even");
else
printf("Odd");
}
#include<iostream.h>
void main()
{
int n;
cout<<"Enter an integer\n";
cin>>n;
if ( n%2 == 0 )
cout<<"\nEven";
else
cout <<"\nOdd";
}
#include <stdio.h>
void main()
{
int year;
printf("Enter a year to check if it is a leap year\n");
scanf("%d", &year);
if(year%400==0 || ((year%4=0) && (year%100!=0)))
printf("%d is a leap year.\n", year); else
printf("%d is not a leap year.\n", year);
}
#include <iostream.h>
void main()
{
int year;
cout<<"Enter a year to check if it is a leap year or not";
cin>>year;
if(year%400==0 || ((year%4=0) && (year%100!=0)))
cout<<"\n"<<year<<"is a leap year."; else
cout<<"\n"<<year<<"is NOT a leap year.";
}
# include <iostream.h>
# include <conio.h>
# include <math.h>
void main ()
{
clrscr();
int a,b=0,sum=0;
long int n;
cout<<"Enter the number to be checked\n ";
cin>>n;
if(n<1)
{
cout<<"\nThe number should be greater than 0";
}
else
{
a=n;
//counting the digits
while (a>0)
{
a=a/10;
b++;
}
a=n;
//adding up bth power of digits
while(a>0)
{
sum=sum+pow(( a%10) ,b);
a=a/10;
}
if(sum==n)
cout<<"\nThe number is an ARMSTRONG number";
else
cout<<"\nThe number is NOT an ARMSTRONG number";
}
getch();
}
# include <stdio.h>
# include <conio.h>
# include <math.h>
void main ()
{
clrscr();
int a,b=0,sum=0;
long int n;
printf("Enter the number to check\n ");
scanf("%i",&n);
if(n<1)
{
printf ("\nThe number should be greater than 0");
}
else
{
a=n;
//counting the digits
while (a>0)
{
a=a/10;
b++;
}
a=n;
//adding up bth power of digits
while(a>0)
{
sum=sum+pow(( a%10) ,b);
a=a/10;
}
if(sum==n)
printf ("\nThe number is an ARMSTRONG number");
else
printf ("\nThe number is NOT an ARMSTRONG number");
}
getch();
}
#include<stdio.h>
#include<string.h>
void main()
{
char a[20];
int i, len;
printf("\nEnter the string:\n");
gets(a);
len = strlen(a);
for (i = 0; i < len / 2; i++)
{
if (a[i] != a[len - i - 1])
break;
}
#include<stdio.h>
struct student
{
char name[5];
int roll;
int mysize;
};
main()
{
unsigned long int b;
printf("size of variable b: %d",sizeof b);
printf("\nsize of int:%d",sizeof(int));
printf("\nsize of float:%d",sizeof(float));
printf("\nsize of char:%d",sizeof(char));
printf("\nsize of long:%d",sizeof(long));
printf("\nsize of double:%d",sizeof(double));
printf("\nsize of short:%d",sizeof(short));
struct student s1;
s1.mysize=sizeof(s1.name)+sizeof(s1.roll)+sizeof(s1.mysize);
printf("\nSizeof structure student :%d",s1.mysize);
/*see the difference shown in size of structure */
printf("\nsize of structure student : %d",sizeof(struct student));
}
#include<stdio.h>
#include<math.h>
void main()
{
int n,sum,r,digits;
for(n=1;n<=1000;n++)
{
digits=0;
r=n;
sum=0;
while(r!=0) //Counting Digits
{
digits++;
r/=10;
}
r=n;
while(r!=0) /*Adding Digits Raised To a Power That Is Equal To Number of Digits */
{
sum+=pow((r%10),digits);
r=r/10;
}
if(sum==n)
{
printf("%5d",sum);
}
}
}
#include<stdio.h>
main()
{
int a[7][7],i,j,k,m,n,temp;
//reading
printf("enter number of rows of matrix\n");
scanf("%i",&m);
printf("enter number of columns of matrix\n");
scanf("%i",&n);
printf("enter the elements\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
//displaying
printf("the matrix you entered:\n");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
{
printf("%4d",*(*(a+i)+j));
}
}
#include<stdio.h>
main ()
{
unsigned int a = 60; /* 60 = 0011 1100*/
unsigned int b = 13; /* 13 = 0000 1101 */
printf ("a=60 ( 0011 1100)\nb=13 ( 0000 1101)\n");
int c = 0;
c = a&b ; /* 12 = 0000 1100 */
printf ("a&b=%d\n",c );
c = a | b ; /* 61 = 0011 1101 */
printf ("a|b=%d\n",c );
c = a ^ b ; /* 49 = 0011 0001 */
printf ("a^b=%d\n", c );
c = ~ a; /*-61 = 1100 0011 */
printf ("~a=%d\n" , c );
c = a << 2 ; /* 240 = 1111 0000 */
printf ("a<<2=%d\n" , c );
c = a >> 2 ; /*15 = 0000 1111*/
printf ("a>>2=%d\n" , c );
}
#include<stdio.h>
void main()
{int a[10][10],i,m,j;
int det=0;
printf("\nEnter the order of matrix:\n ");
scanf("%i",&m);
printf("\nenter elements\n");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
scanf("%d",&a[i][j]); }
printf("\nThe matrix is\n");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<m;j++)
printf("%3d",a[i][j]);
}
printf("\nthe transpose is\n");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
printf("%3i",a[j][i]);
printf("\n");
}
if(m==1)
{
det=a[0][0];
printf("det=%i",det);
}
#include<stdio.h>
#include<conio.h>
long factorial(int);
main()
{
int i, n, c;
printf("Enter the number of rows you wish to see in pascal triangle\n");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
for (c = 0; c <= (n - i - 2); c++)
printf(" ");
for (c = 0; c <= i; c++)
printf("%ld ", factorial(i) / (factorial(c) * factorial(i - c)));
printf("\n");
}
getch();
}