1. Printing 100~200 the prime number between
#include <stdio.h>
#include <math.h>
int main ()
{
inti,j,n=0;
printf ("The prime number between the numbers is : \ n");
for (i=100;i<=200;i++)
{
For (J=2;j<sqrt (i); j + +)
{
if (i%j==0)
Break
Else
{
if (j>sqrt (i)-1)
{
printf ("%d", I);
n++;
if (n%5==0)
printf ("\ n");
}
Else
Continue
}
}
printf ("\ n");
return 0;
}
2. Output Multiplication Table
#include <stdio.h>
int main ()
{
Inti,j;
for (i=1;i<=9;i++)
{
for (j=1;j<=i;j++)
{
printf ("%d*%d=%d", i,j,i*j);
}
printf ("\ n");
}
Return0;
}
3. not allowed to create temporary variables, exchange two number of content
#include <stdio.h>
int main ()
{
Inta,b;
printf (" Please enter two number : \ n");
scanf ("%d%d", &a,&b);
A=a^b;
B=b^a;
A=a^b;
printf ("a=%d,b=%d", A, b);
printf ("\ n");
Return0;
}
There are a number of ways to exchange two numbers without creating a temporary variable, which can be different or, plus or minus.
4. The maximum value in the number of
#include <stdio.h>
int main ()
{
Inta[10],i,max;
printf (" Please enter a number : \ n");
for (i=0;i<9;i++) {
scanf ("%d", &a[i]);
}
printf ("\ n");
MAX=A[0];
for (i=1;i<9;i++)
{
if (Max<a[i])
{
Max=a[i];
}
}
printf ("The biggest number is :%d\n", Max);
Return0;
}
5. Swapping the contents of array A and the contents of Group B
#include <stdio.h>
void swap (int *a,int *b,int N)
{
inti,tmp;
for (i=0;i<n;i++)
{
Tmp=a[i];
A[i]=b[i];
b[i]=tmp;
}
}
void Main ()
{
intx[5]={1,2,3,4,5};
inty[5]={6,7,8,9,0};
inti,n=5;
Swap (x,y,5);
printf ("x:");
for (i=0;i<n;i++)
printf ("%d", x[i]);
printf ("\ny:");
for (i=0;i<n;i++)
printf ("%d", y[i]);
printf ("\ n");
Return0;
}
6. Ask for two number of greatest common divisor
#include <stdio.h>
int main ()
{
Inta,b,c,t;
printf (" Please enter 2 number : \ n");
scanf ("%d%d", &a,&b);
if (a< b)
{
T=a;
A=b;
b=t;
}
C= a%b;
while (c!= 0)
{
A= b;
b= C;
C= a%b;
}
printf ("The greatest common divisor of these two numbers is :%d\n", b);
return 0;
}
Personally feel that writing procedures is gradual, the most important thing is to think more, more practice, accumulate some methods every day, time is long, understand more, encountered programming problems easy to start.
A small example of C-language starter programming