NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

NevLabs

Under Construction

Sunday, August 7, 2011

Matrix addition


#include<stdio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,row,col;
clrscr();
printf("How many rows : ");
scanf("%d",&row);
printf("How many columns : ");
scanf("%d",&col);
printf("Enter your 1st matrix :\n");
for(i=0;i<row;++i)
   for(j=0;j<col;j++)
      {
      printf("Element(%d,%d) :",i+1,j+1);
      scanf("%d",&a[i][j]);
      }

Armstrong numbers upto a given number

#include<stdio.h>
#include<math.h>
void main()
{
int num,sum,lim,dig,temp;
clrscr();
printf("Enter the limit :");
scanf("%d",&lim);
printf("\nArmstrong num upto %d are :\n",lim);
for(num=1;num<=lim;++num)
   {
   for(temp=num,sum=0;temp>0;temp/=10)

Largest and smallest among n numbers

#include<stdio.h>
void main()
{
int n,i=1,num,big,small;
clrscr();
printf("Among how many numbers : ");
scanf("%d",&n);
if(n<0)
  printf("invalid input");
else
  {
  printf("Enter number %d :",i);
  scanf("%d",&num);
  big=small=num;
  for(;i<n;++i)
     {
     printf("Enter number %d :",i+1);
     scanf("%d",&num);
     if(big<num)
       big=num;
     if(small>num)
       small=num;
     }

Matrix subtraction

#include<stdio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],d[10][10],i,j,row,col;
clrscr();
printf("How many rows : ");
scanf("%d",&row);
printf("How many columns : ");
scanf("%d",&col);
printf("Enter your 1st matrix :\n");
for(i=0;i<row;++i)
   for(j=0;j<col;j++)
      {
      printf("Element(%d,%d) :",i+1,j+1);
      scanf("%d",&a[i][j]);
      }

To generate pattern 333 22 1

#include<stdio.h>

void main()
{
int i,j,n;
clrscr();
printf("how many lines you need to print :");
scanf("%d",&n);
for(i=n;i>0;i--)
   {
   for(j=0;j<i;j++)
      {
      printf("%d",i);
      }
    printf("\n");
   }
getch();
}

To display the 1st n prime numbers

#include<stdio.h>
#include<math.h>

void main()
{
int i,num,lim,flag,count=0;
clrscr();
printf("Enter the no.of prime numbers:");
scanf("%d",&lim);
printf("1st %d prime numbers are :\n",lim);
for(num=2;count<lim;++num)
   {
   flag=1;
   for(i=2;i<=sqrt(num);++i)

To generate pattern 1 12 123

#include<stdio.h>

void main()
{
int i,j,n;
clrscr();
printf("how many lines you need to print :");
scanf("%d",&n);
for(i=0;i<n;i++)
   {
   for(j=0;j<=i;j++)
      {
      printf("%d",j+1);
      }
    printf("\n");
   }
getch();
}

To generate pattern 321 21 1


#include<stdio.h>

To generate pattern * ** ***


#include<stdio.h>

To generate pattern*** ** *


#include<stdio.h>

To generate pattern 1 12 123


#include<stdio.h>

Number in reverse


#include<stdio.h>

Sum of individual digits of a number


#include<stdio.h>

Convert temperature in degree celcius to farenheit

#include<stdio.h>