isosceles right triangle

#include<stdio.h>
int main(){
	int a,b;
	printf("How many steps?");
	scanf("%d",&a);
	b=a;
	for(int i=b;i!=0;i--){
		for(int k=b;k!=i-1;k--){
			printf("*");
		}
		printf("\n");
	}
}

equilateral triangle

#include<stdio.h>
int main(){
	int a0,a1;
	printf("How Many Step?");
	scanf("%d",&a0);
	a1=a0;
	for(int i=0;i!=a0;i++){
		for(int k=a0;k!=i;k--){
			printf(" ");
		}
		for(int k=i+1;k!=0;k--){
			printf("*");
			printf(" ");
		}
		printf("\n");
	}
}

Composite Number

#include<stdio.h>
int main(){
	int a,temp;
	scanf("%d",&a);
	printf("Up to what number?");
	for(int i=1;i!=a+1;i++){
		temp=0;
		for(int k=1;k!=i;k++){
			if(i%k==0){
				temp++;
			}
			if(i==k*k){
				temp++;
			}
		}
		if(temp>2){
			printf("%d is a composite number\n",i);
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *