3.38
Write a program that prints 100 asterisks, one at a time. After every tenth asterisk, your program should print a newline character. [Hint: Count from 1 to 100. Use the remainder operator to recognize each time the counter reaches a multiple of 10.]
C Program:
#include <stdio.h>Output:
int main(){ int a, b;
for(a=0; a<=10; a++){
for(b=0; b<=10; b++) { printf("*"); }
printf("\n");
}
system("pause");
}
3.39 (Counting 7s)
Write a program that reads an integer and determines and prints how many digits in the integer are 7s.C Program:
#include <stdio.h>Output:
int main(){
int input, temp, sisa = 0, seven = 0;
printf("Masukan angka: ");
scanf("%d", &input);
temp=input;
while(temp!=0){
sisa=temp%10;
if(sisa==7) {seven++;}
temp/=10;
}
printf("Jumlah angka 7 ada %d angka.\n", seven);
system("pause");
}
3.40 (Checkerboard Pattern of Asterisks)
Write a program that prints 100 asterisks, one at a time.
#include <stdio.h>Output:
#include <stdlib.h>
int main()
{
int side =8;
int row;
int mod;while( side >=1) {
row =8;
mod = side %2;
while( row >=1) {
if( mod !=0) {
printf(" ");mod =0;
}
printf("* ");
--row;
}
printf("\n");
--side;
}
system ("PAUSE");
BalasHapuscongratulations my friend. I am a student of access science in Brazil. your blog is helping me a lot. thanks for the contribution to knowledge.
congratulations my friend. I am a student of computer science in Brazil. your blog is helping me a lot. thanks for the contribution to knowledge.
Hapus