#include<stdio.h>
#include<conio.h>
int x;
main()
{
x=1;
while (x<=10)
{
printf("%d\n",x);
x++;
}
getch();
}
Thursday, 20 October 2011
Wednesday, 19 October 2011
page 94 #9
#include<stdio.h>
#include<conio.h>
#define PONG printf
#define LORO scanf
int x, y;
int main()
{
for (x = 1; x<10;x++)
{
for(y=1;y<x;y++)
PONG("*");
PONG("\n",x);
}
getch();
return 0;
}
#include<conio.h>
#define PONG printf
#define LORO scanf
int x, y;
int main()
{
for (x = 1; x<10;x++)
{
for(y=1;y<x;y++)
PONG("*");
PONG("\n",x);
}
getch();
return 0;
}
Example Ni sir!!/* Program to reverse the digits of a number */
#include<stdio.h>
#include<conio.h>
int main()
{ int num, rightdigit;
printf("Enter a number \n");
scanf("%d", &num);
while (num != 0)
{
rightdigit = num % 10;
printf("%d", rightdigit);
num = num / 10;
} printf("\n");
getch();
return 0;
}
#include<conio.h>
int main()
{ int num, rightdigit;
printf("Enter a number \n");
scanf("%d", &num);
while (num != 0)
{
rightdigit = num % 10;
printf("%d", rightdigit);
num = num / 10;
} printf("\n");
getch();
return 0;
}
Tuesday, 18 October 2011
page 83 #9
#include<stdio.h>
#include<conio.h>
#define PONG printf
#define LORO scanf
int main()
{
int temp;
PONG("Enter temperature: ");
LORO("%d",&temp);
if ( temp < 20 )
{
PONG("IT'S COLD!");
}
else
if ( temp > 30 )
{
PONG("IT'S HOT!");
}
else
{
PONG("COOL CLIMATE!");
}
getch ();
return 0;
}
page 83
#include<stdio.h>
#include<conio.h>
#define PONG printf
#define LORO scanf
int main()
{
int MG, MB, FE;
float FG;
char SN;
PONG("Enter student's name:\n ");
LORO("%s",&SN);
PONG("Enter midterm grade:\n ");
LORO("%d",&MG);
PONG("Enter minor B:\n ");
LORO("%d",&MB);
PONG("Enter final exam:\n ");
LORO("%d",&FE);
FG = ( MG * .30 ) + ( MB * .10 ) + ( FE * .60 );
PONG("Your final grade is %.2f or equivalent to ",FG);
if( FG >= 98 && FG <= 100)
{
PONG("4.00");
}
else
if( FG >= 95 && FG <= 97)
{
PONG("3.75");
}
else
if( FG >= 92 && FG <= 94)
{
PONG("3.50");
}
else
if( FG >= 89 && FG <= 91)
{
PONG("3.25");
}
else
if( FG >= 86 && FG <= 88)
{
PONG("3.00");
}
else
if( FG >= 83 && FG <= 85)
{
PONG("2.75");
}
else
if( FG >= 80 && FG <= 82)
{
PONG("2.50");
}
else
if( FG >= 77 && FG <= 79)
{
PONG("2.25");
}
else
if( FG >= 74 && FG <= 76)
{
PONG("2.00");
}
else
if( FG >= 71 && FG <= 73)
{
PONG("1.75");
}
else
if( FG >= 68 && FG <= 70)
{
PONG("1.50");
}
else
if( FG >= 64 && FG <= 67)
{
PONG("1.25");
}
else
if( FG >= 60 && FG <= 63)
{
PONG("1.00");
}
else
{
PONG("0.00");
}
getch ();
return 0;
}
example page 93 # 4
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int x, y , z, t, a;
x= 1; y= 2; z= 3;
for (a= 1; a <4; a++)
{
z=z+x;
x=y+z;
t=z;
z=y;
y=x;
x=t;
p("%d%d%d\n",x,y,z);
}
getch();
return 0;
}
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int x, y , z, t, a;
x= 1; y= 2; z= 3;
for (a= 1; a <4; a++)
{
z=z+x;
x=y+z;
t=z;
z=y;
y=x;
x=t;
p("%d%d%d\n",x,y,z);
}
getch();
return 0;
}
example page 93 # 3
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int x, y;
for(x=2; x <=4; x++);
for (y = 5; y>= 3; y--);
p("%d\n",x+y);
getch();
return 0;
}
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int x, y;
for(x=2; x <=4; x++);
for (y = 5; y>= 3; y--);
p("%d\n",x+y);
getch();
return 0;
}
example page 93 # 2
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int M, N, Z, H;
M= 6;
N= 0;
for(H =1; H <= M; H++)
{
Z = 2 * H ;
N = N + 3;
p("H = %d\n", H);
p("z = %d\n", Z);
p("n = %d\n", N);
}
getch();
return 0;
}
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int M, N, Z, H;
M= 6;
N= 0;
for(H =1; H <= M; H++)
{
Z = 2 * H ;
N = N + 3;
p("H = %d\n", H);
p("z = %d\n", Z);
p("n = %d\n", N);
}
getch();
return 0;
}
Review Program ni Sir!
#include<stdio.h>
#include<con
int x,y,z,m;
int main()
{
printf("Enter Number: ");
scanf("%d",&y);
printf("Enter another Number: ");
scanf("%d",&z);
for(x = 1; x <= y; x++)
{
m = y * z;
printf("%d x %d = %d\n",y,z,m);
}
getch();
return 0;
}
#include<con
int x,y,z,m;
int main()
{
printf("Enter Number: ");
scanf("%d",&y);
printf("Enter another Number: ");
scanf("%d",&z);
for(x = 1; x <= y; x++)
{
m = y * z;
printf("%d x %d = %d\n",y,z,m);
}
getch();
return 0;
}
Conditional (GRADE)
#include<stdio.h>
#include<conio.h>
#define p printf
#define s scanf
int grade;
int main()
{
p("Enter Grade of Student: ");
s("%d",&grade);
if(grade >= 60)
p("You Pass It!!");
else
p("Sorry you failed!");
getch();
return 0;
}
#include<conio.h>
#define p printf
#define s scanf
int grade;
int main()
{
p("Enter Grade of Student: ");
s("%d",&grade);
if(grade >= 60)
p("You Pass It!!");
else
p("Sorry you failed!");
getch();
return 0;
}
Thursday, 13 October 2011
A program that will get the average of all intergers from 1 - 10 using do-while loop
#include<stdio.h>
#include<conio.h>
int main()
{
int x, sum;
float average;
{
sum= 0;
x= 1;
do
{
x++;
sum = sum + x;
}while (x<=10);
average = sum / 10.00;
printf("The Computed average is %.2f\n",average);
}
getch();
return 0;
}
#include<conio.h>
int main()
{
int x, sum;
float average;
{
sum= 0;
x= 1;
do
{
x++;
sum = sum + x;
}while (x<=10);
average = sum / 10.00;
printf("The Computed average is %.2f\n",average);
}
getch();
return 0;
}
IF TOPC
#include<stido.h>
#include<conio.h> int main(){ int x,y; printf("Enter value for x :"); scanf("%d",&x); printf("Enter value for y :"); scanf("%d",&y); if ( x > y ){ printf("X is large number - %d\n",x); } else{ printf("Y is large number - %d\n",y); } return 0;
getch();
}
TOPIC NEW
#include
#include
int main()
{
int i,y;
printf("Enter Number: ");
scanf("%d",&y);
for (i=0; i<=y; i+=2)
{
printf ("%d\n",i);
}
getch();
return 0;
}
Wednesday, 12 October 2011
#3.PAGE 81
#include<stdio.h>
#include<conio.h>
#define p printf
#define s scanf
int main()
{
int hw, hr, pong;
p("Enter hours worked for the week:");
s("%d",&hw);
p("Enter the hourly rate:");
s("%d",&hr);
if(hw > 45)
{
pong = (hw * hr) - 500;
}
else
{
if (hw > 40 && hw <= 45)
pong = (hw * hr) - 250;
}
{
if(hw > 35 and hw <=40)
pong = (hw * hr) - 150;
p("\nYour Total salary is %d",pong);
}
getch();
return 0;
}
#include<conio.h>
#define p printf
#define s scanf
int main()
{
int hw, hr, pong;
p("Enter hours worked for the week:");
s("%d",&hw);
p("Enter the hourly rate:");
s("%d",&hr);
if(hw > 45)
{
pong = (hw * hr) - 500;
}
else
{
if (hw > 40 && hw <= 45)
pong = (hw * hr) - 250;
}
{
if(hw > 35 and hw <=40)
pong = (hw * hr) - 150;
p("\nYour Total salary is %d",pong);
}
getch();
return 0;
}
Subscribe to:
Posts (Atom)