- C is building block for many other currently known languages.
- Learning C provides a strong procedural background with worthy skill set.
- Language constructs in C such as “if” statements,”for”,”while” loops and types of variables can found in many modern language.
- For a programmer who hasn’t learned something like C, will face difficulty in handling concepts like pointers, data types, passing values by reference.
- Knowing C takes you closer to the hardware, to better understand how things work on system.
- Many blocks of operating systems like UNIX, Linux & windows are coded in C, because no other language stands when it comes to performance.
- While learning C++ or JAVA we come across concepts like class, objects, inheritance, polymorphism, templates etc, which are very difficult to understand without being comfortable with basics.
Goal of this blog is to provide programming material to beginners. At present this blog contains the stuff related to C programming and Data structures with C like mini-projects codes ,some simple C codes and tutorials. (use Google chrome to browse this blog) HAPPY PROGRAMMING!!
Tuesday, 19 February 2013
Why C?
Wednesday, 13 February 2013
C program to get size of a file (approx.)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char c,name[10];
long int size=0;
clrscr();
printf("Enter the file name with extension(like .txt,.c,.cpp):");
scanf("%s",name);
fp=fopen(name,"r");
if(fp==NULL)
{
printf("Unable to open the file");
getch();
exit(5);
}
while((fscanf(fp,"%c",&c))!=EOF)
size++;
printf("Size of file: %ld bytes",size);
getch();
}
C program which prints its code.
/*Save this program as proprint.c*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void
main()
{
FILE
*fp;
char
ch;
clrscr();
fp=fopen("proprint.c","r");
if(fp==NULL)
{
printf("Unable
to open");
getch();
exit(5);
}
while(fscanf(fp,"%c",&ch)!=EOF)
printf("%c",ch);
getch();
}
Sunday, 10 February 2013
C programs for pascal triangle
/* Method 1*/
unsigned long int fact (int a);
int main(){
int i,j,k,n;
printf("Enter the number:");
scanf("%d",&n);
for(i=0;i<n;i++){
k=0;
for(j=0;j<n;j++){
if(i+j>=n-1){
printf(" %d",fact(i)/(fact(k)*fact(i-k)));
k++;
}
else
printf(" ");
}
printf("\n");
}
return 0;
}
unsigned long int fact(int a)
{
unsigned long int q,w=1;
for(q=1;q<=a;q++)
w=w*q;
return(w);
}
/* Method 2*/
#include<stdio.h>
#include<conio.h>
void main()
{
int
l,i,r=0,sum=0,sp;
clrscr();
printf("Enter
the req. number of lines\n");
scanf("%d",&l);
while(r<l)
{
for(sp=30-2*r;sp>0;sp--)
printf("
");
for(i=0;i<=r;i++)
{
if(i==0||r==0)
sum=1;
else
sum=(sum*(r-i+1))/i;
printf("%4d",sum);
}
printf("\n");
r++;
}
getch();
Fill you screen with smiley icon
/*ASCII value of Smiley Icon is 1.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int y;
clrscr();
for(y=1; y<=1000; y++)
printf("%2c",1);
getch();
}
Saturday, 9 February 2013
Some use full comands in turbo C
Alt+F9 = Compile
Character right Right
Line up Up
Line down Down
Scroll up Ctrl-W
Scroll down Ctrl-Z
Page up PgUp
Page down PgDn
End of line End
Beginning of file Ctrl Home
End of file Ctrl End
Delete line Ctrl-Y
Mark block end ctrl-KK
Copy marked block ctrl-KC
Move marked block ctrl-KV
Delete Marked Block ctrl-KY
Write block to file ctrl-KW
Read from a file ctrl-KR
To unmark the block ctrl-QY
Load file F3
Save F2
Quit TurboC alt-X
Find ctrl-QF
To add watch ctrl+F7
Ctrl+F9 = Compile+Link+Run
Basic Cursor Movement Commands.
Character left LeftCharacter right Right
Line up Up
Line down Down
Scroll up Ctrl-W
Scroll down Ctrl-Z
Page up PgUp
Page down PgDn
Quick Cursor Movement Commands.
Beginning of line HomeEnd of line End
Beginning of file Ctrl Home
End of file Ctrl End
Insert and Delete Commands.
Insert Mode On/Off InsertDelete line Ctrl-Y
Block Commands.
Mark block begin ctrl-KBMark block end ctrl-KK
Copy marked block ctrl-KC
Move marked block ctrl-KV
Delete Marked Block ctrl-KY
Write block to file ctrl-KW
Read from a file ctrl-KR
To unmark the block ctrl-QY
Miscellaneous Commands.
Load file F3
Save F2
Quit TurboC alt-X
Find ctrl-QF
To add watch ctrl+F7
To find meaning of key word ctrl+F1
To save the program F2
To open the file F3
Undo Alt+BkSp
Redo Shift+Alt+BkSp
Close Alt+F3
User screen Alt+F5
Trace into F7
Step over F8
Saturday, 2 February 2013
C programming books.
- Let us C-Yashavant Kanetkar.
- Programming in ANSI C- Balaguruswamy.
- Head first C , by David Griffiths and Dawn Griffiths
- Click here for more books-http://www.cprogramming.com/books/c.html
Subscribe to:
Posts (Atom)