Programing Language C
Programing C,C Programing,Programing language,Programing language C,Programing simplified,Programing language list,Programing tutorial,Programing Code,Programing contest,C Programming problems,C Programming language
Tuesday, February 23, 2016
How to do Insertion sort Program
#include<stdio.h>
int main(){
int a[10],i,n,m,c=0,l,u,mid;
printf("Enter the size of an array: ");
scanf("%d",&n);
printf("Enter the elements in ascending order: ");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("Enter the number to be search: ");
scanf("%d",&m);
l=0,u=n-1;
while(l<=u){
mid=(l+u)/2;
if(m==a[mid]){
c=1;
break;
}
else if(m<a[mid]){
u=mid-1;
}
else
l=mid+1;
}
if(c==0)
printf("The number is not found.");
else
printf("The number is found.");
return 0;
}
int main(){
int a[10],i,n,m,c=0,l,u,mid;
printf("Enter the size of an array: ");
scanf("%d",&n);
printf("Enter the elements in ascending order: ");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("Enter the number to be search: ");
scanf("%d",&m);
l=0,u=n-1;
while(l<=u){
mid=(l+u)/2;
if(m==a[mid]){
c=1;
break;
}
else if(m<a[mid]){
u=mid-1;
}
else
l=mid+1;
}
if(c==0)
printf("The number is not found.");
else
printf("The number is found.");
return 0;
}
Saturday, December 5, 2015
Basic in c programming.
Basic in c programming.
1 st I write a program after analysis the code, that witch code how work ?
Sum between 2 number.
#include<stdio.h>
int main()
{
int a,b,sum;
printf("Enter the value of a ");
scanf("%d",&a);
printf("Enter the value of b");
scanf("%d",&b);
sum= (a+b);
printf("Sum is %d", sum);
getch();
return 0;
}
Analysis:
#include<stdio.h> is header file. stdio.h for basic input output.
int main() this is main function and you have to write code in the "{}".
int for integer data type.
a.b.sum is veriable.
printf() for output.
scanf() for input.
getch() for program window stay till you close the window.
Hope it will help you.
1 st I write a program after analysis the code, that witch code how work ?
Sum between 2 number.
#include<stdio.h>
int main()
{
int a,b,sum;
printf("Enter the value of a ");
scanf("%d",&a);
printf("Enter the value of b");
scanf("%d",&b);
sum= (a+b);
printf("Sum is %d", sum);
getch();
return 0;
}
Analysis:
#include<stdio.h> is header file. stdio.h for basic input output.
int main() this is main function and you have to write code in the "{}".
int for integer data type.
a.b.sum is veriable.
printf() for output.
scanf() for input.
getch() for program window stay till you close the window.
Hope it will help you.
Subscribe to:
Posts (Atom)