



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Source code and discussion for six programming assignments in c language focusing on using loops to solve various problems. Students will learn how to write algorithms using while and for loops, find prime numbers, calculate sum of squares, and reverse the digits of a given number.
Typology: Essays (university)
1 / 6
This page cannot be seen from the preview
Don't miss anything!




#include <stdio.h> int main(void) { int x, y, z; for (y = 0; y < 7; y++) { { for (x = 1; x < (7 - y); x++) printf(" "); for (z = 1; z < (y + 2); z++) printf("*"); } printf("\n"); } return 0; }
#include <stdio.h> int main(void) {
while (y < (x + 1)) { if ((x % y) == 0) num = (num + 1); y++; } if (num == 2) printf("%d ", x); x++; } } printf("\n"); return 0; }
/1^2 +2^2 +3^2 +...+n^2 의 값을 계산하여 출력하는 프로그램/ #include <stdio.h> int main(void) { int x = 1, n, answer = 0; printf("n의 값을 입력하시오: "); scanf("%d", &n); while (x < (n + 1))
answer = (answer + x*x); x++; } printf("계산값은 %d입니다.\n", answer); return 0; }
#include <stdio.h> int main(void) { int N, x; printf("정수를 입력하시오: "); scanf("%d", &N); if (N < 0) printf("오류! 양수를 입력하시오."); else do { x = N % 10; printf("%d", x); N = N / 10; } while (N > 0);