Its Gives Latest Tech News Updates

It gives latest mobiles updates laptops updates

It gives latest Teachnology updates

It will gives Latest Opreating System Updates

It will Provides Various materials

It will Provides Smaple Examples Programming Materials.

Showing posts with label C Language. Show all posts
Showing posts with label C Language. Show all posts

Monday, 5 February 2018

c language tutorial for beginners | how to study c programming language | c programming blog

Introduction To C language


c language tutorial for beginners
Reading, processing and writing of data are the three essential functions of a computer Program.Most programs take some data as input and  display the processed data often known as information or results.There are two methods of providing data to the program data to the  program variables.One

Sunday, 21 January 2018

Program for String Length


Program for String Length
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char a[10],m,b[10];
clrscr();
printf("input any string\n");

scanf("%s",a);
m=strlen(a);
printf("%d\n",m);
printf("%s",strrev(a));
getch();
                                                              }

Program For Sorting | general c programs |


Program For Sorting
#include<stdio.h>
#include<conio.h>
main()
{
int a[50],n,i,j,t;
clrscr();
printf("input the no of items u want to sort\n");
scanf("%d",&n);
printf("input the value's to be sorted\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{

if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("the sorted elements are\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
getch();
}

Program for Reverse Number


Program for Reverse Number
#include<stdio.h>
#include<conio.h>
main()
{
int a,r,rev=0;
clrscr();
printf("enter the value of a");
scanf("%d",&a);
while(a!=0)
{
r=a%10;
rev=rev*10+r;
a=a/10;
}
printf("The reverse no of the given no is=%d",rev);
getch();

}

Program for Square root | Example Program



Program for Square root
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b,c,d;
float r,r1,r2;
clrscr();
printf("enter the values a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=((b*b)-(4*a*c));
if(d==0)
{
r=-b/(2*a);
printf("roots are equal=%f",r);
}

else if(d>0)
{
r1=((-b)+sqrt(d))/(2*a);
r2=((-b)-sqrt(d))/(2*a);
printf("%f\n%f",r1,r2);
}
else
        printf("roots are imaginary");
getch();
}

Program for Matrix Multiplaction | Sample program for Matrix |



Program for Matrix Multiplaction
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],b[10][10],c[10][10],i,j,m,n,o,p,k;
clrscr();
printf("input the order of A&B matrice's\n");
scanf("%d%d%d%d",&m,&n,&o,&p);
if(n==o)
{
printf("matrice's can be multiplied\n");
printf("input matrix A\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{

scanf("%d",&a[i][j]);
}
printf("\n");
}
printf("input matrix B\n");
for(i=0;i<o;i++)
{
for(j=0;j<p;j++)
{
scanf("%d",&b[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<p;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
                        printf("%5d",c[i][j]);

}
printf("\n");
}
}
else
printf("matrice's cannot be multiplied");
getch();
}

Program for Flyorid Traingle


Program for Flyorid Traingle
/*floyd triangle*/
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,t=1,n;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)

{
printf("%3d",t);
t=t+1;
}
printf("\n");
}
getch();
}

Program for FIBANOCHI


Program for FIBANOCHI
#include<stdio.h>
#include<conio.h>
main()
{
int a,i=0,f0=0,f1=1,f;
clrscr();
printf("enter the value of a");
scanf("%d",&a);
printf("%d\n",f0);
printf("%d\n",f1);
do
{       f=f0+f1;

printf("%d\n",f);
f0=f1;
f1=f;
i++;
}while(i<a-1);
getch();
}




Program for Compound Interest


Program for Compound Interest
/*programme to cal compound intrest*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int p,r,n;
float ci;
printf("enter the values of p,r,n");
scanf("%d%d%d",&p,&r,&n);
ci=p*(pow(((1+r)/100),n));
printf("ci=%f\n",ci);
getch();
}

Program for Factorial


Program for Factorial
/*factorial*/
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,f=1;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(i=1;i<=n;++i)
{
f=f*i;
}
printf("%d",f);
getch();

}

Program for Even or Odd


Program for Even or Odd
/*check even or odd*/
#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
printf("enter the value of a");
scanf("%d",&a);
if(a%2==0)
{
printf("%d is even",a);
}
else
printf("%d is odd",a);
getch();

}

Program for Traingle


Program for Traingle
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j,t=1;
clrscr();
printf("enter the value:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)

{
printf("%3d",t);
t=t+1;
}
printf("\n");
}
getch();
}

Program For Switch Case | Example for Switch Case Program


Program For Switch Case
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
main()
{
int gd=DETECT,gm;
int l,m,n,d,e;
clrscr();
initgraph(&gd,&gm,".");
gotoxy(12,28);
printf("\n\n\n\n\n\n");
printf("\t\t\t");


printf("*****************************");
printf("\t\t\t");
printf("\n\n");
printf("\t\t\tE N T E R  T H E  O P T I O N\n");
printf("\t\t\t");
printf("\n\t\t\t\******************************");
printf("\n\n");
printf("\t\t\t\t    1.ADD\n");
printf("\t\t\t\t    2.SUB\n");
printf("\t\t\t\t    3.DIV\n");
printf("\t\t\t\t    4.MUL\n");
printf("\t\t\t\t    5.EXIT\n");
rectangle(135,75,490,280);
printf("\n");
printf("\t\t\t E N T E R  T H E   V A L U E S:");
scanf("%d",&n);
clrscr();
printf("\n\n\n\n\n\n");
printf("\t\t       E N T E R  T H E  V A L U E :L , M :");
printf("\n");
scanf("%d %d",&l,&m);
gotoxy(12,28);
rectangle(135,75,490,280);
clrscr();

switch(n)
{
case 1:
d=l+m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ A D D T I O N = % d",d);
printf("\n\n       P R O G R A M    H A S  E N D  F O R   T H I S    O P E R A C T I O N");
break;
case 2:
d=l-m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ S U B T R A C T = % d",d);
printf("\n\n");
printf("\n       P R O G R A M   H A S  E N D  F O R  T H I S    O P E R A C T I O N");
break;
case 3:
d=l/m;
e=l%m;
printf("\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ Q U E F I C E N T = % d\n",d);
printf("\n");
printf("\t\t\t\t\ R E M I N D E R = % d",e);
printf("\n\n");
printf("\tP R O G R A M   H A S   E N D  F O R  T H I S  O P E R A C T I O N");
break;
case 4:
d=l*m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ M U L T I P L A Y = % d",d);
printf("\n\n");
printf("    P R O G R A M    H A S    E N D    F O R   T H I S   O P E R A C T I O N");
break;
case 5:
exit();
default:
break;
}
getch();
}

Program for Simple Interest


Program for Simple Interest
#include<stdio.h>
#include<conio.h>
void main()
{
int year,per=10,pri=5000;
float amt,val,intr;
clrscr();
amt=pri;
intr=0.11;
year=0;
printf("  Simple  Interest  As  Per  Year");
printf("\n _________________________________");

printf(" \n Year     Amount:");
while(year<=per)
{
printf("\n%5d      %8.2f\n",year,amt);
val=amt+intr*amt;
year=year+1;
amt=val;
}
/*printf("      -----------");
printf("\n      ___________"); */
getch();
}

Simple Interest 1 Program


Simple Interest 1 Program
#include<stdio.h>
#include<conio.h>
main()
{
int p,t,r,si;
clrscr();
printf("enter the values of p,t,r");
scanf("%d%d%d",&p,&t,&r);
si=(p*t*r)/100;

printf("%d",si);
getch();
}

Program for Phyramid 2

Program for Phyramid 2
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j,k;
clrscr();
printf("enter the number:");
scanf("%d",&n);
printf("\n\n\n\n\n\n\n");
for(i=1;i<=n;i++)
{

for(k=1;k<=40-i;k++)
printf(" ");
for(j=1;j<=2*i-1;j++)
printf("%d",j);
printf("\n");
}
getch();
}

Program for Read File


Program for Read File
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fp;
char ch;
clrscr();
fp=fopen("sunil.c","r");
if(fp==NULL)
{
printf("file not found.....");
}
else
{
while(!feof(fp))
{
ch=fgetc(fp);
printf("%c",ch);
delay(1000000);
}
}
getch();
fclose(fp);
}�

Program for Reverse the Number


Program for Reverse the Number
#include<stdio.h>
#include<conio.h>
main()
{
int a,r,rev=0;
clrscr();
printf("enter the value of a");
scanf("%d",&a);
while(a!=0)
{
r=a%10;
rev=rev*10+r;

a=a/10;
}
printf("The reverse no of the given no is=%d",rev);
getch();

}

Program for Prime Number


Program for Prime Number
#include<stdio.h>
#include<conio.h>
main()
{
int n,a,j,i,t=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
t=0;
for(i=2;i<=j-1;i++)
{
a=j%i;
if(a==0)
{
t=t+1;

}
}
if(t==0)
printf("%d\n",j);
}

getch();
}�

Program for Perfect Number


Program for Perfect Number
#include<stdio.h>
#include<conio.h>
main()
{
int n,n1,i,a,j=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
n1=n;
for(i=1;i<n;i++)
{
a=n%i;
if(a==0)
j=j+i;
}
if(j==n1)
printf("the sum of factors of given number is perfect=%d",j);
else
printf("the sum of factors of given number is not perfect=%d",j);
getch();
}�