C Program To find equivalent resistance of Parallel combination of resistive circuits

C Program To find equivalent resistance of Parallel combination of resistive circuits | C assignment to find equivalent resistance in C language | Program to find equivalent resistance when value of Resistance is given




#include
#include

int main()
{
int r[10],num,i,Rs=0;
clrscr();

printf("Enter the number of Resistances : ");
scanf("%d",&num);

printf("\nEnter Value of Each Resistance : \n");
for(i=0;i<num;i++)
{
printf("\nR%d : ",i+1);
scanf("%d",&r[i]);
}

for(i=0;i<num;i++)
{
Rs = Rs + r[i];
}

printf("\nEquivalent Series Resistance : %d Kohm",Rs);

getch();
}


Related Links :

C Program to add number using Command line Arguments Parameters

C Program to Add two numbers using Command Line Arguments Parameters | C Program to add number using Command line Arguments Parameters | Command Line Arguments in C Language | Passing parameters by Command Line Arguments in C language






#include

void main(int argc , char * argv[])
{
int i,sum=0;

if(argc!=3)
{
printf("Oops....!! \n you have forgot to type numbers. \n");
exit(1);
}

printf("The sum is : ");

for(i=1;i<argc; i++)
sum = sum + atoi(argv[i]);

printf("%d",sum);

}







How Run Program?

Step 1 : Write a Program

Step 2 : Open Command Prompt inside Borland C/C++.

Step 3 : Click on DOS Shell.

Step 4 : Inside Command Prompt type this command.

C:\TC\BIN>add 10 20

Step 5 : Hit Enter , You will get following Output.



C:\TC\BIN>add 10 20

The sum is : 30

C:\TC\BIN>




Related Links :

Incrementing Array of Float Pointer in C

Incrementing Array of Float Pointer in C



#include

int main(){

float var[5]={1.1f,2.2f,3.3f};
float(*ptr)[5];

ptr=&var;
printf("Value inside ptr : %u",ptr);

ptr=ptr+1;
printf("Value inside ptr : %u",ptr);

return 0;
}








Output :


Value inside ptr : 1000
Value inside ptr : 1020

Related Links :

Creating Triangle of Numbers in C

Creating Triangle of Numbers in C


1
2 1
1 2 3 2 1
2 3 4 3 2 1
1 2 3 4 5 4 3 2 1



# include 
# include 
void main ( )
{
clrscr ( );
int n,i,j,k;
printf ("\n Enter no. of rows :");
scanf ("%d",&n);
printf ("\n\n");
for (i =1;i < = n;i++)
{
for (j = 1;j < = n-i;j++)
printf (" ");
for (j = i;j > =1;j--)
printf ("%d",j);
for (j = 2;j < = i;j++)
printf ("%d",j);
printf ("\n");
}
getch ( );
}


Related Links :

C Program Decimal number to Octal Conversion | Decimal to Octal Conversion in C

C Program Decimal number to Octal Conversion | Decimal to Octal Conversion in C | C Language assignment to convert Decimal Value to Octal Value 



#include
#include
#include

void dec_oct(long int num)   // Function Decl.
{
long int rem[50],i=0,length=0;
while(num>0)
 {
 rem[i]=num%8;
 num=num/8;
 i++;
 length++;
 }
printf("\n Converted Octal number is : ");
     for(i=length-1;i>=0;i--)
             printf("%ld",rem[i]);
}





void main()
{
long int num;
clrscr();
 
 printf("Enter the decimal number : ");
 scanf("%ld",&num);

    dec_oct(num);   // Calling function

 getch();
}


Related Links :

C Program to Convert Decimal number into Hexadecimal | Decimal to Hexadecimal Conversion in C

C Program to Convert Decimal number into Hexadecimal | Decimal to Hexadecimal Conversion in C | C Language assignment to convert Decimal Number to Hexadecimal 



#include
#include
#include

void dec_hex(long int num)   // UDF
{
long int rem[50],i=0,length=0;

while(num>0)
   {
      rem[i]=num%16;
      num=num/16;
      i++;
      length++;
   }

printf("\n Hexadecimal number : ");
for(i=length-1;i>=0;i--)
  {
    switch(rem[i])
    {
      case 10:
          printf("A");
          break;
      case 11:
          printf("B");
          break;
      case 12:
          printf("C");
          break;
      case 13:
          printf("D");
          break;
      case 14:
          printf("E");
          break;
      case 15:
          printf("F");
          break;
      default :
         printf("%ld",rem[i]);
    }
  }
}
//================================================
void main()
{
long int num;
clrscr();

 printf("Enter the decimal number : ");
 scanf("%ld",&num);

    dec_hex(num);   // Calling function

 getch();
}



Related Links :

C Program to Convert Binary to Decimal number | Binary to Decimal Conversion in C

C Program to Convert Binary to Decimal number | Binary to Decimal Conversion in C | C Language Assignment to convert Binary Value to Decimal Value 



#include
#include
#include

void bin_dec(long int num)   // Function declaration
{
long int rem,sum=0,power=0;
while(num>0)
 {
 rem = num%10;
 num = num/10;
 sum = sum + rem * pow(2,power);
 power++;
 }

printf("\n Converted Decimal number is : %d",sum);
}



// END of Function




void main()
{
long int num;
clrscr();

printf(" Please Enter the Binary number (0 and 1 only): \n");
scanf("%ld",&num);

bin_dec(num);

getch();
}


Related Links :

C Program to Convert Decimal to Binary using Bitwise and operator | C Program to Convert to Decimal to binary

C Program to Convert Decimal to Binary using Bitwise and operator | C Program to Convert to Decimal to binary | Decimal to binary conversion in C language



#include
#include

void binary(unsigned int); 

void main()
{
unsigned int num;
printf(" Please Enter Any Decimal Number : ");
scanf("%u",&num);
binary(num);   // Function Call
getch();
}




// Function Starts 
void binary(unsigned int num)
{
unsigned int mask=32768;   //mask = [1000 0000 0000 0000]
printf("\n The Binary Eqivalent is : ");

while(mask > 0)
   {
   if((num & mask) == 0 )
         printf("0");
   else
         printf("1");
  mask = mask >> 1 ;  // Right Shift
   }
}



Related Links :

C Program Reverse all words not string | Reverse Words only from given String in C

C Program Reverse all words not string | Reverse Words only from given String in C | C assignment to reverse Word only

C program to accept a string from user and reverse all words but not string using pointer.



/*c program for reverse all words but not string using pointer*/

#include
#include
int main()
{
 char str[30];
 char *p,*tmp;
 printf(" Enter any string : \n");
 gets(str);
 for(p=str; *p!='\0'; p++)
 {
  if(*(p+1)==' ' || *(p+1)=='\0')
  {
   for(tmp=p; *tmp!=' ' && tmp>=str; tmp--)
     printf("%c",*tmp);
  }
  printf(" ");
 }
 getch();
 return 0;
}

OUTPUT :
Enter Any String : 
Life is Good


efiL si dooG

Related Links :

c program to print all ASCII Values using loop

c program to print all ASCII Values using loop | Printing ASCII Values in C | Printing All 255 Ascii Characters in C


#include
#include
int main()
{
 int i;
 printf("ASCII table & its equivalent values with numbering: \n");
 for(i=1; i<=255; i++)
 printf("\nValue: %d -> ASCII character: %c",i,i);
 getch();
 return 0;
}



Related Links :

C Program to Diagonally Add elements | Diagonal addition of elements of matrix in C

C Program to Addition of Diagonal Elements in Matrix | C Program to Diagonally Add elements | Diagonal addition of elements of matrix in C



#include
#include

void main()
{
int i,j,a[10][10],sum,m,n;

/* m - Number of rows 
   n - Number of Columns   */

printf("\n Enter the number of Rows : ");
scanf ("%d",&m);

printf("\n Enter the number of Columns : ");
scanf ("%d",&n);

/* Accept the Elements in m x n Matrix */

for(i=0;i<m;i++ )
       for(j=0;j<n;j++)
       {
       printf("Enter the Element a[%d][%d] : ", i , j);
       scanf("%d",&a[i][j]);
       } 

/* Addition of all Diagonal Elements */

sum = 0;

for(i=0;i<m;i++ )
       for(j=0;j<n;j++)
       {
        if ( i == j )   
        sum = sum + a[i][j]; 
       } 

/*  Print out the Result */

printf("\nSum of All Diagonal Elements in Matrix : %d",sum); 

getch();

}



Enter the number of Rows : 2

Enter the number of Columns : 2

Enter the Element a[0][0] : 1
Enter the Element a[0][1] : 1
Enter the Element a[1][0] : 1
Enter the Element a[1][1] : 1

The Addition of All Elements in the Matrix : 2

Related Links :

C Program to Addition of All Elements in Matrix | Summation of Elements of matrix in c

C Program to Addition of All Elements in Matrix | Summation of Elements of matrix in c



#include
#include

void main()
{
int i,j,a[10][10],sum,m,n;

/* m - Number of rows 
   n - Number of Columns */

printf("\n Enter the number of Rows : ");
scanf ("%d",&m);

printf("\n Enter the number of Columns : ");
scanf ("%d",&n);

/* Accept the Elements in m x n Matrix */

for(i=0;i<m;i++)
       for(j=0;j<n;j++ )
       {
       printf(" \n Enter the Element a[%d][%d] : ", i , j);
       scanf("%d",&a[i][j]);
       } 

/* Addition of all Elements */

sum = 0;

for(i=0;i<m;i++ )
       for(j=0;j<n;j++ )
       {
       sum = sum + a[i][j]; 
       } 

/* Print out the Result */
printf("\nThe Addition of All Elements in the Matrix : %d",sum); 
getch();
}





Enter the number of Rows : 2
Enter the number of Columns : 2

Enter the Element a[0][0] : 1
Enter the Element a[0][1] : 1
Enter the Element a[1][0] : 1
Enter the Element a[1][1] : 1

The Addition of All Elements in the Matrix : 4


Related Links :

Reading 2-D Array Elements In C | Retrieving Elements from two Dimension Arrays

Reading 2-D Array Elements In C | Retrieving Elements from two Dimension Arrays 

 


#include
#include
void main()
{
int i,j,a[3][3];

/* i = For Counting Rows
j = For Counting Columns */

/* two loops will Accept 9 elements from user */

for(i=0;i<3;i++)
   for(j=0;j<3;j++)
   {
   printf("\n Enter the a[%d][%d] = ",i,j);
   scanf("%d",&a[i][j]);
   }

/* Print 9 elements */

for(i=0;i<3;i++)
{
   for(j=0;j<3;j++)
      printf("%d\t",a[i][j]);
printf("\n");
}

getch();
}


Related Links :

Simple sorting of numeric array in C | C Program to Sort Numbers by Simple Sorting Method

Simple sorting of numeric array in C | C Program to Sort Numbers by Simple Sorting Method | Simple Sorting method Example in C Language



#include < stdio.h >
#include < conio.h > 

void main()
{
	int a[20];
	int i,j,n;
	clrscr();
	printf("\n Enter value for n: ");
	scanf("%d",&n);
	printf("\n Enter %d values \n",n);
	for(i=0; i < n ; i++)
	{
		scanf("%d", &a[i]);
	}
	printf(" %d values before sorting are \n",n);
	for(i=0; i < n; i++)
	{
		printf("%4d",a[i]);
	}
	simple_sort(a,n);
	printf("\n %d values after sorting are \n",n);
	for(i=0;in;i++)
	{
		printf("%4d",a[i]);
	}
}
int simple_sort(int a[],int n)
{
	int i,j,t;
	for(i = 0;i < n-1;i++)
	{
		for(j= i + 1;j < n;j++)
		{
			if(a[i]>a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
 return;
}


Related Links :

C Program to Counting total number of nodes in a tree

C Program to Counting total number of nodes in a tree



#include
#include
struct tree_node
{
 int data;
 struct tree_node *left,*right,*parent;
};
typedef struct tree_node node;
node * new_node(int x);
node * insert_node(node *root, int x);
int count_nodes(node *root);

int main()
{
 node *root=NULL;
 int i,x,max;
 printf("how many numbers do you want to enter in tree?\n");
 scanf("%d",&max);
 printf("Enter %d numbers \n",max);
 for(i=0;i<max;i++)
 {
  scanf("%d",&x);
  root = insert_node(root, x);
 }
 printf("all numbers inserted into the tree\t press enter to count");
 fflush(stdin);
 getchar();
 printf("\nThere are total %d nodes in this tree\n",count_nodes(root));
    return 0;
}

node * insert_node(node *root, int x)
{
 if(!root)
 {
  root = new_node(x);
  return root;
 }
 if(root->data > x)
  root->left = insert_node(root->left,x);
 else
  root->right = insert_node(root->right,x);
 return root;
}

int count_nodes(node *root)
{
 if(!root)
 return 0;
 else
 return(count_nodes(root->left) + 1 + count_nodes(root->right));
}

node * new_node(int x)
{
 node *furnished;
 furnished = (node*)malloc(sizeof(node));
 furnished->data=x;
 furnished->left=NULL;
 furnished->right=NULL;
 furnished->parent=NULL;
 return furnished;
}


Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!