0% found this document useful (0 votes)
15 views6 pages

E. Laporan Resmi: Listing Program

The document contains 7 code snippets written in C programming language. Each snippet contains a for loop to perform a specific task: 1) Print numbers from 1 to 20 2) Calculate the triangular number corresponding to a user-input number 3) Print the alphabet from A to Z 4) Print the alphabet from Z to A 5) Print odd numbers up to a user-input number 6) Print the alternating sum of integers up to a user-input number 7) Calculate and print the factorial of integers up to a user-input number

Uploaded by

rifqy hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

E. Laporan Resmi: Listing Program

The document contains 7 code snippets written in C programming language. Each snippet contains a for loop to perform a specific task: 1) Print numbers from 1 to 20 2) Calculate the triangular number corresponding to a user-input number 3) Print the alphabet from A to Z 4) Print the alphabet from Z to A 5) Print odd numbers up to a user-input number 6) Print the alternating sum of integers up to a user-input number 7) Calculate and print the factorial of integers up to a user-input number

Uploaded by

rifqy hidayat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

E.

LAPORAN RESMI
Listing Program

1. #include <stdio.h>

#include <stdlib.h>

int main()

int a;

printf("Menampilkan nilai 1 sampai 20\n");

for(a=1;a<=20;a++){

printf("%d ",a);

return 0;

}
#include <stdio.h>
2.
#include <stdlib.h>

int main()

int n,input,tringular=0;

printf("masukan angka:");

scanf("%d",&n);

input =n;

for(;n!=0;n--){

tringular=tringular+n;

printf("bilangan tringular dari %d adalah :


%d",input,tringular);

return 0;

}
3.
#include <stdio.h>

#include <stdlib.h>

int main()

char a;

for(a='A'; a<='Z';a++)

printf("%c\n", a);

return 0;

#include <stdio.h>

#include <stdlib.h>

int main()
4. {

char a;

for(a='Z';a>='A';a--){

printf("%c\n",a);

return 0;

}
5.
#include <stdio.h>

#include <stdlib.h>

int main()

int n,m;

printf("Masukan nilai :");

scanf("%d",&n);

int i;

i=1;

for(i;i<n;i++){

m=2*i-1;

printf(" %d\n",m);

return 0;

}
6.
#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

int n,m;

printf(" Masukan angka :");

scanf("%d",&n);

for(int i=1;i<=n;i++){

m=pow(-1,i-1)*i;

printf("%d\n ",m);

return 0;

}
7. #include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

int m = 1,n,i;

printf("masukan nilai :");

scanf("%d",&n);

for(i=1;i<=n;i++){

m=(m*i);

printf("%d\n",m);

You might also like