C Language Tutorial

 C language tutorial for beginners Urdu/Hindi:


Well Come to C language tutorial code section, here you can copy lecturer code easily and apply them in your own IDE. If you have any trouble feel free to write comment!
For videos you can click below link:
Enjoy C Language 
FOR Video LECTURER: CLICK_HERE

From Tutorial 1 to 7

printf("Hi, I am new user of C language!\n");
int a=12;
char b='e';
float c=12.5033f;
double e=45.2333333;
  
printf("The value of a: %d\n",a);
printf("The value of c: %c\n",b);
printf("The value of c: %f\n",c);
printf("The value of e:%lf\n",e);
  
printf("%d\n",sizeof(int));
printf("%d\n",sizeof(char));
printf("%d\n",sizeof(float));
printf("%d\n",sizeof(double));
              
//integer=4 bytes == 32bits max=2147483647 min=-2147483648
//Character=1 bytes == 8bits ==256 no negative value
//Float=4 bytes == 32bits max=2147483647 min=-2147483648
//Double=8 bytes == 64bits max=9223372036854775807 min=9223372036854775808
  
int aa=-2147483648; ;
printf("The value of aa: %d\n",aa);
char bb ='c';
printf("The value of bb: %c\n",bb);
float cc=2147483647.564f;
printf("The value of cc: %f\n",cc);
double dd=9223372036854775807.564;
printf("The value of dd: %lf\n",cc);

unsigned int a=1;
unsigned short int b=-1;
unsigned long int c=2;
signed int aaa=-1;
signed short int d=-231;
signed long int e=-561;

printf("%u\n",a);
printf("%hu\n",b);
printf("%lu\n",c);
printf("%d\n",aaa);
printf("%hd\n",d);
printf("%ld\n",e);

printf("\n\n\n");
printf("%d\n",sizeof(unsigned int));
printf("%d\n",sizeof(unsigned short int));
printf("%d\n",sizeof(unsigned long int));
printf("%d\n",sizeof(signed int));
printf("%d\n",sizeof(signed short int));
printf("%d\n",sizeof(signed long int));

char a='1';
signed char bb='1';
unsigned char cc='1';
printf("%d\n",sizeof(char));
printf("%d\n",sizeof(signed char));
printf("%d\n",sizeof(unsigned char));
printf("%c\n",a);
printf("%c\n",bb);
printf("%c\n",cc);
long double dd =123.1234006;
printf("%Lf\n",dd);

FOR Video LECTURER: CLICK_HERE

From Tutorial 7 to 13

nt a=2, b=2, add, mul,sub, div, mod,mix;
add = a+b;
mul=a*b;
sub=a-b;
div=a/b;
mod=a%b;
mix=(a + b)* a * (b % a);

printf("%d\n",add);
printf("%d\n",mul);
printf("%d\n",sub);
printf("%d\n",div);
printf("%d\n",mod);
printf("MIX: %d\n",mix);
                  
//Relational Operator (> ,< , >= ,<=, !=, ==)
printf("%d\n", 5 > 4);
printf("%d\n", 5 < 4);
printf("%d\n", 5 >= 4);
printf("%d\n", 5 <= 4);
printf("%d\n", 5 != 4);
printf("%d\n", 5 == 4);
  
//Assignment Operator in C (=,+=, -=, *=, /=, %=)
//All Operation will be performed using update the operator

int z=10;
z=z%2;
printf("%d\n", z);
//+=
z=2;
printf("%d\n", z);

//Logical Operator in C (&&, ||, !)
  
int a=1, b=2, c=3, d=4;
int result1 = ( (a==b) && (c<d) ) || (d==4);
printf("%d\n",result1);
  
int result2 = (a==b) || (c<d);
printf("%d\n",result2);
  
int result3 =!(a==b);
printf("%d\n",result3);
  
//ternary Operatory (? :)
int zz = (a!=b) ? 20 : 30;
printf("%d\n",zz);

//Bitwise operator
// Operator &, | , ^, ~, >>, <<
int a=3;//  0010
int b=2;

printf("%d\n",a | b);
printf("%d\n",a & b);
printf("%d\n",a ^ b);
printf("%d\n",~a);
printf("%d\n",a >> b);
printf("%d\n",a << b);

FOR Video LECTURER: CLICK_HERE

From Tutorial 14

//if statement family (if, if-else, if-elseif, if-elseif-else)
//only if family
int age;
printf("Enter your age\n");
scanf("%f",&age);
if(age>=18)
{
printf("Your age is 18 or 18 Plus");
}
//if with else
int age;
printf("Enter your age\n");
scanf("%d",&age);
  
if(age>=18)
{
printf("Your Enter Age is: [%d]",age);
}
else
{
printf("Here is your Default Else Condition!");
}
// if elseif

int age;
printf("Enter your age\n");
scanf("%d",&age);

if(age>=18)
{
printf("Your Enter Age is: [%d]",age);
}
else if(age<=18)
{
printf("Your Enter  Age is less then 18: [%d]",age);
}


// if elseif + else

int age;
printf("Enter your age\n");
scanf("%d",&age);

if(age>=18)
{
printf("Your Enter Age is: [%d]",age);
}
else if(age<=18)
{
printf("Your Enter  Age is less then 18: [%d]",age);
}
else
{
printf("Default, else");
}

FOR Video LECTURER: CLICK_HERE

From Tutorial 15 to 18

//Loop:
// for loop
//i++, i=i+1
//i=i+10
//i+=10
int i,j;
for (i=0; i<10;i++)
{
printf("The value of i is now: %d\n",i);
for(j=0;j<=10;j++)
{
printf("The value of j is now: %d\n",j);
}
}

//While Loop in C
int i=11;
while(i<=10)
{
printf("The value of i is now: %d\n",i);
i++;
}


//Do While loop
int i=11;
do
{
printf("The value of i is now: %d\n",i);
i++;
}
while(i<=10);


   //Loop MashUp
int i;
for(i=0;i<=10;i++)
{
printf("For loop value: %d\n",i);
int j=0,k=0;
while (j<=10)
{
printf("While loop value: %d\n",j);
j++;
}
do
{
printf("Do-While loop value: %d\n",k);
k++;
}while(k<=10);

}

FOR Video LECTURER: CLICK_HERE

From Tutorial 18 to 20

// Switch Case in C ( work like as if-else) 
// Including the nested switch 

int i=1;
switch(i)
{
case 1:
{
printf("The value of i is 1");
int ii=1;
switch(ii)
{
case 1:
{
printf("NEsted Value of ii is 1");
break;
}
case 2:
{
printf("NEsted Value of ii is 2");
break;
}
default:
{
printf("Nested Default!");
}
}
break;

}
case 2:
{
printf("The value of i is 2");
break;
}
case 3:
{
printf("The value of i is 3");
break;
}
default:
{
printf("Default!");
}
}

FOR Video LECTURER: CLICK_HERE

// Jump Statements in C (break, continue, goto)
//break
int i;
for(i=1;i<=10;i++)
{
if(i==5)
{
continue; //BREAK
}
printf("%d\n",i);
}


FOR Video LECTURER: CLICK_HERE
//goto

printf("This is first line of code\n");
printf("This is second line of code\n");

goto one;
printf("This is third line of code\n");
printf("This is fourth line of code\n");

one:
{
printf("This is fifth line of code\n");
printf("This is sixth line of code\n");
printf("This is seventh line of code\n");
}


FOR Video LECTURER: CLICK_HERE
// Logic Building Practice Question
// (using all concept what ever we learnt so far...

//PROBLEM 1
//Table according to the user
int table,i;
printf("Enter you table Number\n");
scanf("%d",&table);
// 2 * 1 = 2
for(i=1;i<=10;i++)
{
//printf("%d * %d = %d\n",table,i, table*i);
printf("%d *",table);
printf("%d =",i);
printf("%d",table*i);
printf("\n");
}

//PROBLEM 2
int i;
for(i=1;i<=7;i++)
{
if(i==7)
{
printf("%d",i);
break;
}
printf("%d, ",i);
}

//PROBLEM 3
int i;
for(i=3;i<=25;i=i+5)
{
if(i==23)
{
printf("%d",i);
break;
}
printf("%d, ",i);
}
int i;
for(i=20;i>=-10;i=i-6)
{
if(i==-10)
{
printf("%d",i);
break;
}
printf("%d, ",i);
}

//PROBLEM 4

int i;
for(i=19;i<=51;i=i+8)
{
if(i==51)
{
printf("%d",i);
break;
}
printf("%d, ",i);
}



FOR Video LECTURER: CLICK_HERE
///Logic Building Session # 02:
////Logic building 2
//PROBLEM 5
// sum of (1-10) number to display
int i; int sum=0; for(i=1;i<=5;i++) { sum=sum+i; //0+1+2+3+4+..10 } printf("The sum of 1 to 5 numbers are: %d",sum); //PROBLEM 6

//Sum of the sequence of integer provided by user int i=0; int sum=0,numqty,number; printf("Enter the number of integer to sum togther?\n"); scanf("%d",&numqty); for (i=1;i<=numqty;i++) { printf("Enter integer number one by one to sumup\n"); scanf("%d",&number); sum =sum+ number; } printf("The sum of User's entered values: %d",sum);
//PROBLEM 7//int avg = 1+2+3+4+5/5; //printf("%d",avg); int i=0, num; float count=0; float avg; int sum=0; while(num!=9999) { printf("Enter an integer besites 9999, if you press 9999 the program exit"); scanf("%d",&num); if(num==9999) { break; } else { sum=sum+num; count++; i++; } } avg=sum/count; printf("The AVG of entered numbers is: %f", avg);  

//PROBLEM 8
//int z, c=3;
//if(a>=b && b>=c) //{ //z=a; //} //else //{ //z=b; //} int number, value, smallest, i,largest; printf("Enter your number of integers... to find which one is smalles\n"); scanf("%d",&number); printf("Enter your first integer\n"); scanf("%d",&smallest); for(i=2;i<=number;i++) { printf("Enter you next values\n"); scanf("%d",&value); if(value<smallest) { smallest=value; } else if(value>smallest) { largest=value; } } printf("The Smallest value is: %d\n",smallest); printf("The Largest value is: %d\n",largest);

//PROBLEM 9int i; int sum=0,sum1=0; for(i=1;i<=10;i++) { if(i%2==0) { //2 %2 sum=sum+i; } if(i%2==1) { //2 %2 sum1=sum1+i; } } printf("The sum of even integer from 2 to 30 : %d\n", sum); printf("The sum of ODD integer from 2 to 30 : %d", sum1);


FOR Video LECTURER: CLICK_HERE
///Logic Building Session # 03:
//PROBLEM 10
printf("Testing \n");
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=5;j++)
{
printf("*");   

}
printf("\n");
}


//PROBLEM 11
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
printf("*");   
}
printf("\n");
}


//PROBLEM 12
int i,j;
for(i=5;i>0;i--)
{
for(j=0;j<i;j++)
{
printf("*");   
}
printf("\n");
}


//PROBLEM 13
int i,j,rows=5,k;
for(i=1;i<=rows;i++)
{
for(j=i;j<rows;j++)
{
printf(" ");   
}
for (k=1;k<=i;k++)
{
printf("*");
}
printf("\n");
}


//PROBLEM 14
int i,j,rows=5,k;
for(i=5;i>=1;i--)
{
for(j=5;j>=i;j--)
{
printf(" ");   
}
for (k=1;k<=i;k++)
{
printf("*");
}
printf("\n");
}


//PROBLEM 5
int row, c, n=5,s=5;
for(row=1; row<=n;row++)
{
for(c=1;c<s;c++)
{
printf(" ");
}
s--;
for( c=1; c<=2*row-1; c++)
{
printf("*");
}
printf("\n");
}


FOR Video LECTURER: CLICK_HERE
From Tutorial 24 to 26


//int a=1,2, float b=23.99, char d='d';
//Array:A series of values but in homogenous sequence.
//1D
//2D
//Jagged Array

//What is index Number in Array
//What is the size of Array
//why we use Array

//Syntax of Array
//Datatype arrayname[Size];

int arr[10];
int arr1[5]={5,3,6,9,7};
size=5
indexs=4
int arr2[];
int arr3[]={1,2,3,4,5,6,7,8,9};

//1D Array element access, with its index number 
int arr[5]={5,3,4,6,9};
int i;
for(i=0;i<5;i++)
{
printf("The element in array %d, at index: %d\n",arr[i],i);
}

// Sum of all element in 1D Array
int arr[6]={5,3,4,6,9,10};
int i,sum=0;
for(i=0;i<6;i++)
{
sum = sum+arr[i]; //0+5, 5+3, 8+4, 12+6, 18+9 ==
}
printf("Sum of Array all elements: %d",arr);

// Sum of all element in 1D Array
int arr[10]={5,3,4,6,9,10,3,4,7,8};
int i,sum=0;
for(i=0;i<10;i++)
{
sum = sum+arr[i]; //0+5, 5+3, 8+4, 12+6, 18+9 ==
}
printf("Sum of Array all elements: %d",sum);
int numofElement=sizeof(arr)/sizeof(int);
double avg=sum/numofElement;
printf("The Average of all element in Array: %lf\n",avg);

int n;
printf("Enter the size of array \n");
scanf("%d",&n);

int arr[n],i;
for(i=0;i<n;i++)
{
printf("Enter the elemnt at index: %d : value: ",i);
scanf("%d",&arr[i]);
}
printf("\n\n\n");
for(i=0;i<n;i++)
{
printf("The element in array %d, at index: %d\n",arr[i],i);
}

// Greatest and smallest values finding from 1D Array
int arr[6]={55,99,4,6,-9,10};
int i,smallest=arr[0], largest=arr[0];
for(i=0;i<6;i++)
{
printf("%d\n",arr[i]);
}
for(i=0;i<6;i++)
{
if(arr[i]>largest)
{
largest=arr[i];
}
if(arr[i]<smallest)
{
smallest=arr[i];
}
}
printf("The largest value in Array arr: %d\n",largest);
printf("The smallest value in Array arr: %d\n",smallest);


//Search Number from Array's Element
int arr[6]={5,99,4,5,-9,10};
int i,search,found;
for(i=0;i<6;i++)
{
printf("%d\n",arr[i]);
}
printf("enter the number to search in Array's elements'");
scanf("%d",&search);

for(i=0;i<6;i++)
{
if(search==arr[i])
{
found=1;
break;
}
else
{
found=2;
}
}
if(found==1)
{
printf("Search number is present");
}
else
{
printf("Search number is not present");

}


FOR Video LECTURER: CLICK_HERE
From Tutorial 27 to 28

/// 2D Array = Dimensional are 2 (rows and columns)
//syntax:
//dataTypes nameofArray[SizeofRow][SizeofColumns];
//int arr[2][2];
//int arr1[3][3]={100,2,3,46,44,6,91,800,7};
//int arr2[2][2]={(1,2),(3,46)};


int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("The value of 2D array %d at index number: [%d%d]\n",arr1[i][j],i,j);
}
}

int i,j,sum =0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum = sum +arr1[i][j];
printf("The value of 2D array %d at index number: [%d%d]\n",arr1[i][j],i,j);
}
}
printf("The sum of 2d Array is: %d\n",sum);
int numberofelemets = sizeof(arr1)/sizeof(int);
//printf("%d\n",numberofelemets);
double avg = sum/numberofelemets;
printf("The Average of 2Darray's Element is: %.2lf",avg);


int i,j,sum =0, evensum=0, oddsum=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum = sum +arr1[i][j];
if(arr1[i][j] % 2== 0)
{
evensum= evensum + arr1[i][j];
}
else
{
oddsum= oddsum + arr1[i][j];
}
}
}
printf("The sum of 2d Array is: %d\n",sum);
printf("The sum of evennumber in 2d Array is: %d\n",evensum);
printf("The sum of oddsum in 2d Array is: %d\n",oddsum);



int i,j,sum =0,greatest=arr1[0][0], smallest=arr1[0][0];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(smallest > arr1[i][j])
{
smallest = arr1[i][j];
}
if(greatest < arr1[i][j])
{
greatest = arr1[i][j];
}
}
}
printf("The smallest value in 2d Array: %d\n",smallest);
printf("The largest value in 2d Array: %d\n",greatest);



FOR Video LECTURER: CLICK_HERE
From Tutorial 29

int *ptr, q;
q = 50;
ptr = &q;
printf("%d", *ptr);


int var = 5;
printf("Value: %d\n", var);
printf("Address: %u", &var);



int *pc, c;
c = 22;
printf("Address of c: %u\n", &c);
printf("Value of c: %d\n\n", c);
 
pc = &c;
printf("Address of pointer pc: %u\n", pc);
printf("Content of pointer pc: %d\n\n", *pc);
 
c = 11;
printf("Address of pointer pc: %u\n", pc);
printf("Content of pointer pc: %d\n\n", *pc);
 
*pc = 2;
printf("Address of c: %u\n", &c);

printf("Value of c: %d\n\n", c);




FOR Video LECTURER: CLICK_HERE
From Tutorial 30 to 31


#include<stdio.h>
void firstFunction();
void secondFunction();
int SumTogether();
int SumwithParameters(int a, int b);

main()
{
firstFunction();
secondFunction();
int z = SumTogether();
printf("%d\n",z);
int y = SumwithParameters(10,2);
printf("%d\n",y);
}
void firstFunction()
{
printf("hi, I am function of C langauge\n");
}

void secondFunction()
{
printf("hi, I am function of C langauge (SecondFunction)\n");
}

int SumTogether()
{
int a=12, b=10;
return a+b;
}
int SumwithParameters(int a, int b)
{
return a+b;

}


--------------


#include<stdio.h>
main()
{
int a=22;
inc(&a);
printf("%d\n",a);
}
void inc(int *ptr)
{
*ptr = *ptr +1;
}

--------------


void swapnum ( int *var1, int *var2 )
{
int tempnum ;
tempnum = *var1 ;
*var1 = *var2 ;
*var2 = tempnum ;
}
int main( )
{
int num1 = 35, num2 = 45 ;
printf("Before swapping:");
printf("\nnum1 value is %d", num1);
printf("\nnum2 value is %d", num2);

swapnum( &num1, &num2 );

printf("\nAfter swapping:");
printf("\nnum1 value is %d", num1);
printf("\nnum2 value is %d", num2);
return 0;
}

FOR Video LECTURER: CLICK_HERE
From Tutorial 32 to 33

/*
The function getchar() stand for get character and  inputs a single character from the keyboard. When call the function waits for a key to be pressed. You can input the character as either a char or //int type because getchar() function treat characters as integers and accept the ASCII value of //character as variable of type int.
*/

//char c;
//c =getchar();
//printf("The value of c is: %c\n",c);


int c;
c =getchar();
printf("The value of c is: %d\n",c);

/*
The getch and getche() are to very similiar function whcih use for  same purpose the gets means it gets some input the ch means it gets a character. The difference between them, the function getche() echoes (display) the character that you types to the screen(the letter a in getche() stands for echo) whereas getch() just returns the character that you types without echoing it on the screen.
*/

char aa ,bb;
printf("Enter a character:");
aa =getche();

//printf("Enter a character:");
//bb =getch();


/*
The function putchar() put character and display only a single char value on the monitor. The char can be a character variable r the character itself contained in single quotes.
*/

putch('xyz');
putchar('abc');

*/
The gets() function enables the user to enter some characters followed by the enter key. All the characters entered by the user get stored in a character array. The null character is added to the array to make it a string. The gets() allows the user to enter the space-se//parated strings. It returns the string entered by the user.
  */

  //puts
int a=12;
puts("The puts function line 1: %d");
puts("The puts function line 2");


*/
The gets() function enables the user to enter some characters followed by the enter key. All the characters entered by the user get stored in a character array. The null character is added to the array to make it a string. The gets() allows the user to enter the space-separated strings. It returns the string
entered by the user.
 /*

 char s[30];
 printf("Enter your string/name");
 gets(s);

 printf("Your Enter name is: %s",s);


______________   ______________


char s[30];
printf("Enter your Name\n");
gets(s);
printf("The entered name is: %s",s);


// strlen() builtin Function of C

char s[30];
printf("Enter your Name\n");
gets(s);
printf("length of string %d",strlen(s));

// strcpy() builtin Function of C

char str1[ ] = "Welcome to" ;
char str2[ ]= " " ;
printf ( "\nSource string = %s", str1 ) ;
printf ( "\nTarget string = %s", str2 ) ;
strcpy( str2, str1) ;
printf ( "\nTarget string after strcpy( ) = %s", str2 );
 

// strcmp () builtin Function of C

char str1[] = "new" ;
char str2[] = "news" ;
int i, j, k ;
i = strcmp ( str1, "new" ) ;
j = strcmp ( str1, str2 ) ;
k = strcmp ( str1, "e" ) ;
printf ( "\n%d %d %d", i, j, k ) ;
 

// strcopy() builtin Function of C

char str1[ ] = "Welcome to" ;
char str2[ ]= "C language" ;
char str3[ ]= "";
strcat ( str1, str2 ) ;  //String Concatenation
printf ( "\nTarget string after strcat( ) = %s\n", str1 ) ;
strcpy(str3,"Hello World"); //String copy
printf("\n %s",str3 );

FOR Video LECTURER: CLICK_HERE
From Tutorial 34 to 36

#define c 1
const a =12;
main()
{
int i =12;
printf("%d\n",i);
i++;
printf("%d\n",i);

printf("%d\n",c);
c++;
printf("%d\n",c);
}



struct info
{
char name[20];
int ID;
double marks
} smp1, smp2, smp[5];
int i, j;
for(i=0;i<5;i++)
{
scanf("%d",&smp[i].ID);
scanf("%lf",&smp[i].marks);
}
for(i=0;i<5;i++)
{
printf("%d\n",smp[i].ID);
printf("%lf\n",smp[i].marks);
}
/*
strcpy( smp1.name,"Fahad Hussain");
smp1.ID =12;
smp1.marks = 12.50;

printf("%s\n",smp1.name);
printf("%d\n",smp1.ID);
printf("%lf\n",smp1.marks);

strcpy( smp2.name,"Ali Hussain");
smp2.ID =50;
smp2.marks = 50.60;

printf("%s\n",smp2.name);
printf("%d\n",smp2.ID);
printf("%lf\n",smp2.marks);




union info
{
char name[20];
int ID;
double marks
} smp1;

strcpy( smp1.name,"Fahad Hussain");
printf("%s\n",smp1.name);

smp1.ID =12;
printf("%d\n",smp1.ID);

smp1.marks = 12.50;
printf("%lf\n",smp1.marks);


FOR Video LECTURER: CLICK_HERE
From Tutorial 37 to 38

#include<stdio.h>
//auto int aa =10; //error
void ABC();

//int a= 150;

main()
{
//What is stroage classes in C
//Auto   //local//within function/method, Stack...
//Register // CPU register
//Extern
//Static


//auto int a =10;
//{
//auto int aa;
//printf("%d\n",aa);
//}

//printf("%d\n",a);


//register int number=12, sum=0, i;

//for(i=1;i<=12;i++)
//{
// sum =sum +i;
//}
/printf("The sum of 1- 12 is: %d",sum);


//extern a;
////printf("%d\n",a);
ABC();
ABC();
ABC();
ABC();
}

void ABC()
{
static int b =12;
printf("%d\n",b);
b++;
}



#include<stdio.h>
main()
{
//Pointer: int *a;

//Basic File Creation
FILE *fp;

//fopen("Fahad.text","")
fp = fopen("test.txt","w");


fp = fopen("test.txt","r");
int ch = fgetc(fp); /*char values are returned in int form  return -1
printf("%d\n",ch);
fclose(fp);



FILE *fp = fopen("test.txt", "a"); /* File already created and data is inserted */
int i,ch;
for(i=65;i<=100;i++)
{
ch = putc(i,fp); /*fputc writes into the file */
To display the contents of the file on the screen */
putchar(ch);
 }
}



FOR Video LECTURER: CLICK_HERE
From Tutorial 39

//What is casting also called (type casting)
// how can we use it in C

int a=17;
int b=3;
double c;

c = (double) a/b;
printf("%lf\n",c);

//char c= 'c';
//int b= 12;


int  a = 25;
char b = 'a'; /* ascii value will be considered
int sum;

//25a
sum = a + b;

printf("%d\n",sum);


FOR Video LECTURER: CLICK_HERE
From Tutorial 40

main()
{
//Fibonacci Series 0,1,1,2,3,5,8 .....
int i;
for (i=0;i<=15;i++)
{
printf("%d ,",fibo(i));
}

///  1!= 1  2! = 2*1,  3! = 3*2*1 =6 ,4!  ...

int ii;
for(ii =0 ;ii<=10;ii++)
{
printf("The fact of is: %d\n",fact(ii));
}
}



 int fibo(int i)
 {
  if(i==0)
  {
  return 0;
}
if(i==1)
  {
  return 1;
}
return fibo(i-1) + fibo(i-2);
 }



 int fact(int i)
 {
  if(i<=1)
  {
  return 1;
}
// 4 == 4*3*2*1
return i * fact(i-1);

 }

2 comments:

  1. It is really helpful and well understood. Can you help in visual c++?

    ReplyDelete
  2. Sir how to make gui based softwares using c language please guide us

    ReplyDelete

Fell free to write your query in comment. Your Comments will be fully encouraged.