#include<stdio.h>#include<conio.h> void main() { if(printf("Hello world")) { } getche(); }
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
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();
}
Monday, 23 July 2012
String Catenation Without Using Strcat Function in C
#include<conio.h>
#include<stdio.h>
void stringconcatenation(char[],char[]);
void main()
{
char str1[100],str2[100];
int compare;
printf("Enter the first string: ");
gets(str1);
printf("Enter the second string: ");
gets(str2);
stringconcatenation(str1,str2);
printf(" The String after concatenation: %s",str1);
getch();
}
void stringconcatenation(char str1[],char str2[])
{
int i=0,j=0;
while(str1[i]!='\0')
{
i++;
}
while(str2[j]!='\0')
{
str1[i] = str2[j];
i++;
j++;
}
str1[i] ='\0';
}
#include<stdio.h>
void stringconcatenation(char[],char[]);
void main()
{
char str1[100],str2[100];
int compare;
printf("Enter the first string: ");
gets(str1);
printf("Enter the second string: ");
gets(str2);
stringconcatenation(str1,str2);
printf(" The String after concatenation: %s",str1);
getch();
}
void stringconcatenation(char str1[],char str2[])
{
int i=0,j=0;
while(str1[i]!='\0')
{
i++;
}
while(str2[j]!='\0')
{
str1[i] = str2[j];
i++;
j++;
}
str1[i] ='\0';
}
Thursday, 19 July 2012
Fibonaaci Series in C
#include<stdio.h>
#include<conio.h>
int main(void)
{
int n,a=0,b=1,c=0,i=1;
printf("How Mnay First Fibonacci Numbers you Want To Generate?\t\t");
scanf("%d",&n);
printf("%d %d",a,b);
while(i<=n-2)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
i++;
}
getch();
return 0;
}
Subscribe to:
Posts (Atom)