Programming For ALL
This website is designed to provide you all codes of C and C++ language and also tutorials for learn the concept of these languages.
Saturday, 4 August 2012
To Print A statement without Using Semicolon
#include<stdio.h>#include<conio.h> void main() { if(printf("Hello world")) { } getche(); }
To print Floyd’s triangle in C language
void main() { int i,j,num; int k=1; printf("Enter the value of range == "); scanf("%d",&num); printf("FLOYD's Triangle\n"); for(i=1;i<=num;i++) { for(j=1;j<=i;j++,k++) { printf(" %d",k); } printf("\n"); } getche(); }
Friday, 3 August 2012
Print Composite Numbers in C
#include <stdio.h>
#include<conio.h>
void composite(int x);
void main()
{
int a;
printf("how much composite number you want to generate = ");
scanf("%d",&a);
composite(a);
getche();
}
void composite(int x)
{
int counter=0,number=0,i=1,j;
while(number<x)
{
counter=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
counter++;
}
if(counter>2)
{
printf("%d ",i);
number++;
}
i++;
}
}
Find The Largest Number Among Three
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,large;
printf("\nEnter 3 numbers:");
scanf("%d %d %d",&a,&b,&c);
large=(a>b&&a>c?a:b>c?b:c);
printf("\nThe biggest number is: %d",large);
getche();
}
Find Power of A Number in C
#include<stdio.h>
#include<conio.h>
void main()
{
int pow,num,i=1;
unsigned long int sum=1;
printf("\nEnter your number == ");
scanf("%d",&num);
printf("\nEnter the desired power ==");
scanf("%d",&pow);
while(i<=pow)
{
sum=sum*num;
i++;
}
printf("\n%d to the power %d is: %ld",num,pow,sum);
getche();
}
Subscribe to:
Posts (Atom)