solution using "for loop" statement #include main(){ int m,e; clrscr(); printf("\t\t\tThe alternate number are the following\n\n"); e=8; for(m=;m<=8;m++){ e--;
Determining the SUM,PRODUCT,AVERAGE,SMALLEST AND LARGEST NUMBER. #include
int main() { int num1, num2, num3, smallest, largest, sum, average, product;
printf("Enter First number: "); scanf("%d",&num1); printf("Enter Second number:"); scanf("%d",&num2); printf("Enter Third number:"); scanf("%d",&num3);
printf ("Sum is: %d",sum ); printf ("\nAverage is: %d",average); printf ("\nProduct is: %d",product); printf ("\nSmallest is: %d",smallest); printf ( "\nLargest is: %d",largest);
int main() { int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array\n"); scanf("%d",&n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ ) scanf("%d",&array[c]);
printf("Enter the number to search\n"); scanf("%d",&search);
for ( c = 0 ; c < n ; c++ ) { if ( array[c] == search ) { printf("%d is present at location %d.\n", search, c+1); count++; } } if ( count == 0 ) printf("%d is not present in array.\n", search); else printf("%d is present %d times in array.\n", search, count);
int main() { int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array\n"); scanf("%d",&n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ ) scanf("%d",&array[c]);
printf("Enter the number to search\n"); scanf("%d",&search);
for ( c = 0 ; c < n ; c++ ) { if ( array[c] == search ) { printf("%d is present at location %d.\n", search, c+1); count++; } } if ( count == 0 ) printf("%d is not present in array.\n", search); else printf("%d is present %d times in array.\n", search, count);
printf("enter a value of the Nautical mile: "); scanf("%f",&n); s= n*0.868976; f=n*6076; printf("the value of nautical mile into statute mile is :%f \n",s); printf("the value of nautical mile into feet is :%d \n",f); getchar(); getchar(); }
#include int main() { int E,R,I; printf("The Current, Resistance and Voltage\n"); printf("Enter The Voltage"); scanf("%d",&E); printf("Enter The Resistance"); scanf("%d",&R); printf("Enter The Current"); scanf("%d",&I); I=E/R; E=I+R; R=E*R; printf("The Value of Current is%d\n",I); printf("The Value of Resistance is%d\n",R); printf("The Value of voltage is%d\n",E); getchar(); getchar(); }
#include int main() { int a,km,hr,sp; printf("CALCULATING TIME, DISTANCE, HOUR\n"); printf("Enter Problem; Km==1,Sp==2,Hr==3:"); scanf("%d",&a); if(a==1) { printf("Enter The Speed:"); scanf("%d", &sp); printf("Enter The Time:"); scanf("%d", &hr); km=sp*hr; printf("The distance is %d",km); printf("km");
} if(a==2) {
printf("Enter Distance:"); scanf("%d", &km); printf("Enter The Time:"); scanf("%d", &hr); sp=km/hr; printf("The Speed is %d",sp); printf("km per hour");
} if(a==3) {
printf("Enter The Distance:"); scanf("%d", &km); printf("Enter The Speed:"); scanf("%d", &sp); hr=km/sp; printf("The Time is %d",hr); printf("hour"); } getchar(); getchar();
#include int main() { int c,u; long int t,e; clrscr();
gotoxy(20,5); printf("the number increasing base"); gotoxy(5,8); printf("enter the desired number:"); scanf("%d",&u); t=1; e=0 for(c=1;c<=u;c++) { t=c*c; e=e+t; } delay(5000); gotoxy(30,15); printf("%d is the total value ",e); gotoxy(25,22); printf("END OF PROGRAM");
#include #include long double fact(unsigned long int n) /*The factorial of a positive integer by recursion*/ { if (n==0) return 1; else return n*fact(n-1); } int main() { long double sum, n; int i, m; printf("\t/*Code to find the approximate value of e */"); check: printf("\n\n\tPlease Enter the value of n := "); scanf("%lf", &n); sum=0; for (i=0; i<=n; i++) sum +=1/(fact(i)); printf("\n\n\tThe appriximate value of e := %.15lg\n\n\t", sum); printf("Let's do this again? 1/ YES Any key/ NO := "); scanf("%d", &m); if (m==1) goto check; else (1); return 0; }
int main(void) { unsigned int un = 3000000000; /* system with 32-bit int */ short end = 200; /* and 16-bit short */ long big = 65537; long long verybig = 12345678908642;
printf("un = %u and not %d\n", un, un); printf("end = %hd and %d\n", end, end); printf("big = %ld and not %hd\n", big, big); printf("verybig= %lld and not %ld\n", verybig, verybig);
#include int main() { int pd,pr,na,vat,tt; printf("PAYMENT HISTORY\n"); printf("\n"); printf("posting date: SEPTEMBER 7,2013\n"); printf("enter a payment ref. no:"); scanf("%d",&pr); printf("enter a net amount:"); scanf("%d",&na); printf("enter a vat"); scanf("%d",&vat);
# include int main () { int pri; int dis; printf("enter price:"); scanf("%d",&pri); printf("enter discount:"); scanf("%d",&dis); dis=pri*0.20; printf("the discount is %d",dis); return 0; }
Ang pwede lang mag post yung member ng blogsite nato tyka dapat kung member na kau login first bago mag comment
TumugonBurahinNaalis ng may-ari ang komentong ito.
BurahinSolution using the "for loop" statement
Burahin#include
int main()
{
int mel,month;
printf("enter the current mortage balance:\n");
printf("Omit $.\n");
scanf("%If",&balance);
printf("enter annual interest rate:\n");
printf("Omit%.")
scanf("%If",&annualrate);
printf("enter monthly payment:\n");
printf("Omit$.");
scanf("%If",&payment);
monthlyrate=annualrate/12.0;
monthlyrate=0.01*monthlyrate;
printf("the next 12 months:\n");
printf("month interes balance\n");
for(mel=1;mel<=50;mel++){
printf("-");
printf("\n\n");
for(month=1;month<12;month++){
interest=monthlyrate*balance;
balance=(balance+interest)-payment;
printf("%10d %10.2lf %10.2lf\n",month,interest,balance);
}
printf("\n enter any keys to return to source code of a program");
getch();
}
solution using "for loop" statement
Burahin#include
main(){
int m,e;
clrscr();
printf("\t\t\tThe alternate number are the following\n\n");
e=8;
for(m=;m<=8;m++){
e--;
delay(1000);
}
getch();
}
Naalis ng may-ari ang komentong ito.
TumugonBurahinDecimal to Binary converter
TumugonBurahin#include
int main()
{
int n,c,k;
printf("Enter Decimal Number\n");
scanf("%d", &n);
printf("The Binary Number is:\n", n);
for (c = 31; c >= 0; c--)
{
k = n >> c;
if (k & 1)
printf("1");
else
printf("0");
}
printf("\n");
getchar();
getchar();
}
Naalis ng may-ari ang komentong ito.
TumugonBurahinNaalis ng may-ari ang komentong ito.
TumugonBurahinFIBONACCI SERIES(multiplication)
TumugonBurahin#include
int main()
{
int n, first = 1, second = 2, next, c;
printf("Enter the number of terms:");
scanf("%d",&n);
printf("First %d terms of Fibonacci series are :\n",n);
for ( c = 1 ; c < n ; c++ )
{
if ( c <= 2 )
next = c;
else
{
next = first * second;
first = second;
second = next;
}
printf("%d\n",next);
}
getchar();
getchar();
}
Determining the SUM,PRODUCT,AVERAGE,SMALLEST AND LARGEST NUMBER.
TumugonBurahin#include
int main()
{
int num1, num2, num3, smallest, largest, sum, average, product;
printf("Enter First number: ");
scanf("%d",&num1);
printf("Enter Second number:");
scanf("%d",&num2);
printf("Enter Third number:");
scanf("%d",&num3);
sum=num1 + num2 + num3;
average=(num1 + num2 + num3) / 3;
product=num1 * num2 * num3;
largest = num1;
if ( num2 > largest )
largest = num2;
if ( num3 > largest )
largest = num3;
smallest = num1;
if ( num2 < smallest )
smallest = num2;
if ( num3 < smallest )
smallest = num3;
printf ("Sum is: %d",sum );
printf ("\nAverage is: %d",average);
printf ("\nProduct is: %d",product);
printf ("\nSmallest is: %d",smallest);
printf ( "\nLargest is: %d",largest);
getchar ();
getchar ();
}
Naalis ng may-ari ang komentong ito.
TumugonBurahin#include
TumugonBurahinint main()
{
int n, reverse = 0;
printf("Enter a number to reverse\n");
scanf("%d",&n);
while (n != 0)
{
reverse = reverse * 10;
reverse = reverse + n%10;
n = n/10;
}
printf("Reverse of entered number is = %d\n", reverse);
getchar();
getchar();
}
TumugonBurahin#include
int main()
{
int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array\n");
scanf("%d",&n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);
printf("Enter the number to search\n");
scanf("%d",&search);
for ( c = 0 ; c < n ; c++ )
{
if ( array[c] == search )
{
printf("%d is present at location %d.\n", search, c+1);
count++;
}
}
if ( count == 0 )
printf("%d is not present in array.\n", search);
else
printf("%d is present %d times in array.\n", search, count);
getchar();
getchar();
}
Naalis ng may-ari ang komentong ito.
TumugonBurahin
TumugonBurahin#include
int main()
{
int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array\n");
scanf("%d",&n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);
printf("Enter the number to search\n");
scanf("%d",&search);
for ( c = 0 ; c < n ; c++ )
{
if ( array[c] == search )
{
printf("%d is present at location %d.\n", search, c+1);
count++;
}
}
if ( count == 0 )
printf("%d is not present in array.\n", search);
else
printf("%d is present %d times in array.\n", search, count);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
float n,s;
int f;
printf("enter a value of the Nautical mile: ");
scanf("%f",&n);
s= n*0.868976;
f=n*6076;
printf("the value of nautical mile into statute mile is :%f \n",s);
printf("the value of nautical mile into feet is :%d \n",f);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int a1,a2,lb,kg,oz,g;
printf("Enter the weight: ");
scanf("%d",&a1);
printf("Enter the name: ");
scanf("%d",&a2);
kg=lb*0.45;
lb=kg*2.2;
oz=g*0.035;
g=oz*28.3;
printf("Ounce: %d\n",oz);
printf("Gram: %d\n",g);
printf("Kilogram: %d\n",kg);
printf("Pound: %d\n",lb);
getchar();
getchar();
}
Naalis ng may-ari ang komentong ito.
Burahin#include
TumugonBurahinint main()
{
float k,c,f;
printf("enter celcius: ");
scanf("%f",&c);
k=(c)+273.15;
f=9/5*(c)+32;
printf("fahrenheit is:%f\n",f);
printf("kelvin is:%f\n",k);
getchar ();
getchar ();
}
#include
TumugonBurahinint main()
{
int n,e,O;
printf("Enter numeber you want:");
scanf("%d",&n);
e=1;
O=0;
do
{
printf("\n%d",e);
O=O+e;
e++;
}
while(e<=n);
printf("\n O is:%d",O);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int a;
int b;
int c;
int d;
int e;
int f;
int g;
printf("the recipe is spaghetti \n");
printf("the first ingredient cost:");
scanf("%d",&a);
printf("the second ingredient cost:");
scanf("%d",&b);
printf("the third ingredient cost:");
scanf("%d",&c);
printf("the fourth ingredient cost:");
scanf("%d",&d);
printf("the fifth ingredient cost:");
scanf("%d",&e);
printf("the sixth ingredient cost:");
scanf("%d",&f);
g=(a+b+c+e+d+f);
printf("the total is %d",g);
if (g<200)
{
printf("CONGRATS");
}
if(g>200)
{
printf ("SORRY");
}
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int E,R,I;
printf("The Current, Resistance and Voltage\n");
printf("Enter The Voltage");
scanf("%d",&E);
printf("Enter The Resistance");
scanf("%d",&R);
printf("Enter The Current");
scanf("%d",&I);
I=E/R;
E=I+R;
R=E*R;
printf("The Value of Current is%d\n",I);
printf("The Value of Resistance is%d\n",R);
printf("The Value of voltage is%d\n",E);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int a,km,hr,sp;
printf("CALCULATING TIME, DISTANCE, HOUR\n");
printf("Enter Problem; Km==1,Sp==2,Hr==3:");
scanf("%d",&a);
if(a==1)
{
printf("Enter The Speed:");
scanf("%d", &sp);
printf("Enter The Time:");
scanf("%d", &hr);
km=sp*hr;
printf("The distance is %d",km);
printf("km");
}
if(a==2)
{
printf("Enter Distance:");
scanf("%d", &km);
printf("Enter The Time:");
scanf("%d", &hr);
sp=km/hr;
printf("The Speed is %d",sp);
printf("km per hour");
}
if(a==3)
{
printf("Enter The Distance:");
scanf("%d", &km);
printf("Enter The Speed:");
scanf("%d", &sp);
hr=km/sp;
printf("The Time is %d",hr);
printf("hour");
}
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
char f,v,t;
printf("Enter Variable Cost:\n");
scanf("%d",&f);
printf("Enter The Fix Cost:\n");
scanf("%d",&v);
t=(f+v)/3;
printf("Enter Total Value %d\n",t);
if(t>=1)
{
printf("Gain");
}
if(t<1)
{
printf("Lost");
}
getchar();
getchar();
}
#include
Burahinmain(){
int m,e
clrs();
printf("\t\t\tThe alternate number are the following\n\n");
e=8;
m=1;
do{
printf("%d %d,",e,m);
e--;
m++;
}while(m<=8);
delay(1000);
getch();
}
#include
TumugonBurahinint main()
{
int c,u;
long int t,e;
clrscr();
gotoxy(20,5);
printf("the number increasing base");
gotoxy(5,8);
printf("enter the desired number:");
scanf("%d",&u);
t=1;
e=0
for(c=1;c<=u;c++)
{
t=c*c;
e=e+t;
}
delay(5000);
gotoxy(30,15);
printf("%d is the total value ",e);
gotoxy(25,22);
printf("END OF PROGRAM");
getch();
}
Naalis ng may-ari ang komentong ito.
TumugonBurahinNaalis ng may-ari ang komentong ito.
TumugonBurahin#include
TumugonBurahin#include
{
int choice;
while (1)
{
printf("\n\nMenu:\n");
printf("1- Math Program\n2- Accounting Program\n");
printf("3- Entertainment Program\n4- Exit");
printf("\n\nYour choice -> ");
scanf("%d",&choice);
switch(choice)
{
case 1 : printf("\nMath Program Runs. !");
break;
case 2 : printf("\nAccounting Program Runs. !");
break;
case 3 : printf("\nEntertainment Program Runs. !");
break;
case 4 : printf("\nProgram Ends. !");
break;
default :
printf("\nInvalid choice");
}
if(choice==4) break;
}
}
Naalis ng may-ari ang komentong ito.
TumugonBurahinNaalis ng may-ari ang komentong ito.
TumugonBurahinNaalis ng may-ari ang komentong ito.
TumugonBurahin#include
TumugonBurahin#include
long double fact(unsigned long int n)
/*The factorial of a positive integer by recursion*/
{
if (n==0)
return 1;
else
return n*fact(n-1);
}
int main()
{
long double sum, n;
int i, m;
printf("\t/*Code to find the approximate value of e */");
check:
printf("\n\n\tPlease Enter the value of n := ");
scanf("%lf", &n);
sum=0;
for (i=0; i<=n; i++)
sum +=1/(fact(i));
printf("\n\n\tThe appriximate value of e := %.15lg\n\n\t", sum);
printf("Let's do this again? 1/ YES Any key/ NO := ");
scanf("%d", &m);
if (m==1)
goto check;
else (1);
return 0;
}
#include
TumugonBurahinint main(void)
{
unsigned int un = 3000000000; /* system with 32-bit int */
short end = 200; /* and 16-bit short */
long big = 65537;
long long verybig = 12345678908642;
printf("un = %u and not %d\n", un, un);
printf("end = %hd and %d\n", end, end);
printf("big = %ld and not %hd\n", big, big);
printf("verybig= %lld and not %ld\n", verybig, verybig);
getchar();
return 0;
}
#include
TumugonBurahinvoid swap (int*a,int*b);
main()
{
int ar [5],i, j,n;
ar[0]=7; ar [1]=3;ar [2]=9; ar[3]=2; ar[4]=n;
printf("Array before sort:\n");
por (1=0;1<5;1++)+
printf("ar[%d]=%d\n",1,ar[i];
n=5; /*number of items in sort array*/
for(1=0;1ar[j+1];
}
printf("Array after sort:\n\n");
for (1=0;1<5; 1++)
printf("ar[%d]=%d\n",1,ar[2];
system ("pause);
return 0;
}
void swap(int*a,int*b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
#include
TumugonBurahinint main()
{
int pd,pr,na,vat,tt;
printf("PAYMENT HISTORY\n");
printf("\n");
printf("posting date: SEPTEMBER 7,2013\n");
printf("enter a payment ref. no:");
scanf("%d",&pr);
printf("enter a net amount:");
scanf("%d",&na);
printf("enter a vat");
scanf("%d",&vat);
tt=na+vat;
printf("\n total amount %d",tt);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int bs,tt,vat,ch;
printf("BILLING DETAILS\n");
printf("\n");
printf("basic charge:");
scanf("%d",&bs);
printf("fcda: -4\n");
printf("environmental charge:48\n");
printf("sewer charge:00.00\n");
printf("maintenance service charge: 1\n");
tt=-4+48+1+bs;
printf("total variable current is %d\n",tt);
printf("vat");
scanf("%d",&vat);
ch=tt+vat;
printf("the current charge is: %d",ch);
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int euro;
int peso;
printf("enter euro. :");
scanf("% d",&euro);
php=euro*58;
printf("the convertion is %d",php)
getchar();
getchar();
}
#include
TumugonBurahinint main()
{
int euro;
int peso;
printf("enter euro. :");
scanf("% d",&euro);
php=euro*58;
printf("the convertion is %d",php)
getchar();
getchar();
}
# include
Burahinint main ()
{
int pri;
int dis;
printf("enter price:");
scanf("%d",&pri);
printf("enter discount:");
scanf("%d",&dis);
dis=pri*0.20;
printf("the discount is %d",dis);
return 0;
}