Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Small program for swaping & average calculation

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

Description : A small program to read the i/pom the terminal and swap their values, Also useful to find the sum & average

#include<stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <time.h>
int i,n;
main()
{
int a,b,swap(),hellow();
/*char getch(),k;*/
char k;
do
{
hellow();
printf("Enter the value of A = ");
scanf("%d",&a);
printf("Enter the value of B = ");
scanf("%d",&b);
printf("values before swaping are
A=%d B=%d<BR>,a,b);
swap(&a,&b);
printf("values after swaping are
A=%d B=%d<BR>,a,b);
printf("Press Y to continue or any other key to Terminate<BR>);
/* printf("Quit? (y/n): ");*/
scanf("%s", &k);
printf("
<BR>);
}
while (k == 'Y' || k == 'y');
return (0);

/* getchar() = k;
if (k=!"N")
{
printf("U can continue<BR>);
main();
}
else
{
printf("U can break<BR>);
goto
} */
}

swap(int*x,int*y)
{
int z;
z=*x;
*x=*y;
*y=z;
return(0);
}

/* #include<stdio.h>
int i,n;
void main() */
hellow()
{
int a[100];
float Avg=0,sum=0;
printf("Enter the value of N = ");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("Enter the values = ");
scanf("%d",&a[i]);
sum=sum+a[i];
}
Avg= (sum/i);
printf("Total=%f,Average=%f<BR>,sum,Avg);
return(0);
}


/*#include <stdio.h>
#include <sys/types.h>
#include <time.h>

main()
abey()

{ int i;
time_t t1,t2;
(void) time(&t1);
for (i=1;i<=300;++i)
printf("%d %d %dn",i, i*i, i*i*i);
(void) time(&t2);
printf("n Time to do 300 squares and cubes= %d secondsn", (int)
t2-t1);
return(0);
}
*/

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG