Professional Documents
Culture Documents
Submitted by:
Pascual, Michael Angel B.
Medina, Dan Esjay
Monzales, Christian Paul
Submitted to:
Ms. Azenith Rollan- Mojica
What is C?
C is what is called a compiled language. This means that once you write
your C program, you must run it through a C compiler to turn your program into an
executable that the computer can run (execute). The C program is the humanreadable form, while the executable that comes out of the compiler is the machinereadable and executable form. What this means is that to write and run a C
program, you must have access to a C compiler (Brain, n.d.).
C was originally developed by Dennis Ritchie between 1969 and 1973 at AT&T
Bell Labs, and used to re-implement the UNIX operating system. It has since
become one of the most widely used programming languages of all time, with
C compilers from various vendors available for the majority of existing computer
architectures and operating systems. C has been standardized by the American
National Standards Institute (ANSI) since 1989 and subsequently by
the International Organization for Standardization (ISO) (C programming language,
2015).
Programming Questions
1. Write a program that will display a pattern depending on n. Assume n as a one
digit odd number.
Example: if n = 9, display
*000*000*
0*00*00*0
00*0*0*00
000***000
1
2
1
2
3. Write a program that reads in a number n, and then reads in n numbers. The
numbers will be alternately added and subtracted.
Example: if n = 5 and the numbers entered are 4, 14, 5, 6, 1
Then compute for 4 + 14 5 + 6 1 = 18
else
{
for (x=n;x>=n-(x-2); x--)
{
for (z=1; z<=n-x; z++)
{
printf("0");
}
for (y=1; y<=1; y++)
{
printf("*", y);
}
for (w=((n-3)/2)-z+1; w>=1; w--)
{
printf("0");
}
for (v=1; v<=1; v++);
{
printf("*");
}
for (w=((n-3)/2)-z+1; w>=1; w--)
{
printf("0");
}
for (y=1; y<=1; y++)
{
printf("*", y);
}
for (z=1; z<=n-x; z++)
{
printf("0");
}
printf("\n");
}
}
getch();
2.
#include<stdio.h>
main()
{
int n, x, y, z;
clrscr();
printf("Set I, no. 2\n\n");
printf("Enter a number (n)\n");
printf("Note that it must only be a one-digit positive number.\n\n");
printf("n = ");
scanf("%d", &n);
printf("\nDisplay:\n\n");
if((n>=10)||(n<=0))
{
printf("Error! Enter only a one-digit positive number.");
printf("\nPlease try again.");
printf("\nThank you. :)");
}
else
{
for (x=1;x<=n; x++)
{
for (z=1; z<=n-x; z++)
{
printf(" ");
}
for (y=x; y>=1; y--)
{
printf(" %d", y);
}
printf("\n");
}
}
getch();
3.
#include<stdio.h>
main()
{
int n, a[10000], x, sum=0,dif=0, ans;
clrscr();
2.
3.
www.dasma.dlsu.edu.ph
References
Brain, M. (n.d.). The basics of C programming. Retrieved October 11, 2015 from
http://computer.howstuffworks.com/c1.htm
C programming language . (2015). In Wikipedia. Retrieved October 11, 2015 from
https://en.wikipedia.org/wiki/C_(programming_language)