You are on page 1of 29

1.

Gathering Negativity

//input, mao nay e butang sa code

#include<stdio.h>

int main()

int num,sn=0;

do{

printf("Enter n: ");

scanf("%d",&num);

if(num<0)

sn=sn+num;

while(num!=0);

printf("Sum of negatives = %d",sn);

return 0;

}
/*output, sunda ang mga numbers nga gibutang like for example;

igka execute nimo sa code kay mangayo nag user input "Enter n: " ana ang mo gawas and then type kag
1, nya enter. Type 3 nya enter. Type -1 nya enter. And so on, sunda lang ang naas problem kanang( 1,
3 ,-1, -2, -4, 5, -1, -2, 0) */

ayaw ra e mind kung akoang butngan ug // ug /**/ kay comment rana sa programming

Additional info:

// is single line comment

/**/ is multiple line comment

pwede na nimo ibutang sa code kung ganahan nimo suwatan

2. "Even" Now
//input

#include<stdio.h>

int main()

int i,n1,n2;

printf("Enter n1: ");

scanf("%d",&n1);

printf("Enter n2: ");

scanf("%d",&n2);

for(i = n2; i >= n1; i--)

if(i%2==0)

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

return 0;

//output
//same process ra gihapon bai pareha sa nag una

3. Negative Fusion

//input

#include<stdio.h>
int main()

float num,sn=0;

do{

printf("Enter n: ");

scanf("%f",&num);

if(num<0)

sn=sn+num;

while(num!=0);

printf("Sum of all negatives = %.3f",sn);

return 0;

//output
//same ra gihapon ang process bai, hahahaha siya ray dili aww

4. The Last 'Zeroes'

//input

#include<stdio.h>

int main (void)


{

int n;

unsigned int c = 0;

printf ("Enter n: ");

scanf ("%d", &n);

while (n && (n % 10 == 0))

++c; n = n / 10;

printf ("Last zeroes count = %u \n",c);

return 0;

//output
5. Not less than three

//input

#include<stdio.h>
int main (void)

int n,i;

printf("Enter n: ");

scanf("%d",&n);

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

if(i>3)

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

return 0;

//output
6. FizzBuzz 2.0

//input

#include<stdio.h>
int main (void)

int n,i;

printf("Enter n: ");

scanf("%d",&n);

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

if(i % 3 == 0)

printf("Fizz");

if(i % 5 == 0)

printf("Buzz");

if(i % 3 && i % 5)

printf("%d",i);

putchar('\n');

return 0;

//output
7. The GCD

//input

#include<stdio.h>
int main (void)

int i,n1,n2,gcd;

printf("Enter the first integer: ");

scanf("%d",&n1);

printf("Enter the second integer: ");

scanf("%d",&n2);

for(i=1; i<=n1 && i<=n2; i++){

if(n1%i==0 && n2%i==0)

gcd=i;

printf("GCD of %d and %d is %d", n1,n2,gcd);

return 0;

//output
1. Square to the Next Level

//input

#include <stdio.h>
int main(void){

int num[100] = {

2, 3, 5, 100, 7, 3, 5, 3, 1, 4,

76, 77, 78, 79, 80, 54, 68, 61, 34, 33,

44, 49, 100, 5, 2, 87, 34, 33, 2, 1,

4, 5, 8, 2, 1, 8, 5, 3, 2, 1,

88, 22, 23, 33, 48, 44, 46, 48, 50, 52,

45, 47, 49, 51, 53, 1, 1, 1, 1, 1,

1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

20, 19, 18, 17, 16, 15, 14, 13, 12, 11,

11, 22, 33, 44, 55, 66, 77, 88, 99, 100,

1000, 2001, 3000, 4001, 5000, 6001, 7000, 8001, 9000, 10001

};

int i;

for(int i = 0; i < 100; ++i){

printf("%d\n", num[i]*num[i]);

return 0;

//output
2. Upper, Dis-upper

//input

#include <stdio.h>
int main() {

int size, i;

int count = 0;

char ch;

printf("Enter the size of the array: ");

scanf("%d ", &size);

for (i = 0; i < size; i++)

scanf("%c", &ch);

if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')

count++;

printf("Count = %d", count);

return 0;

//output
3. Search and Rescue

//input

#include <stdio.h>
int main(){

int a=1,n,e[5],r,i;

printf("Enter the size: ");

scanf("%d",&n);

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

printf("Element #%d: ",a++);

scanf("%d", &e[i]);

printf("Enter the integer to be searched: ");

scanf("%d", &r);

//Research starts from the index 0

i = 0;

while (i < n && r != e[i]) {

i++;
}

if (i < n) {

printf("Present");

} else {

printf("None");

return 0;

//output
4. That One Digit

//input

#include <stdio.h>

#include <string.h>
#include <ctype.h>

int main() {

int n;

printf("Enter the size: ");

scanf("%d",&n);

char c[n];

printf("Enter a character: ");

scanf("%s",&c);

if (isdigit(c[n]) == 0){

printf("That one!");

}else

printf("No one..");

return 0;

//output
5. Arraying 101

//input

#include <stdio.h>

int main() {
int a,values[5];

printf("Enter the size of the array: ");

scanf("%d", &a);

printf("Enter the elements: ");

// taking input and storing it in an array

for(int i = 0; i < 5; ++i) {

scanf("%d", &values[i]);

for(int i = 0; i < 5; ++i) {

printf("%d\n", values[i]);

return 0;

//output
//ang pag input(enter) sa element kay e sumbay ra bai, like type 1 then space, 64 then space, 32 then
space, 2 then space and 11 then enter

6. Arraying 102

//input

#include <stdio.h>
int main(){

int a=1,n,e[5],r,i,a2=1;

printf("Enter the size: ");

scanf("%d",&n);

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

printf("Element #%d: ",a++);

scanf("%d", &e[i]);

printf("\nReverse Order :\n");

for(i=4;i>=0;i--){

printf("Element #%d: ",a2++);

printf("%d\n",e[i]);

return 0;

//output
7. Only the Even Ones

//input

#include <stdio.h>
int main(void){

int num[100] = {

2, 3, 5, 100, 7, 3, 5, 3, 1, 4,

76, 77, 78, 79, 80, 54, 68, 61, 34, 33,

44, 49, 100, 5, 2, 87, 34, 33, 2, 1,

4, 5, 8, 2, 1, 8, 5, 3, 2, 1,

88, 22, 23, 33, 48, 44, 46, 48, 50, 52,

45, 47, 49, 51, 53, 1, 1, 1, 1, 1,

1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

20, 19, 18, 17, 16, 15, 14, 13, 12, 11,

11, 22, 33, 44, 55, 66, 77, 88, 99, 100,

1000, 2001, 3000, 4001, 5000, 6001, 7000, 8001, 9000, 10001

};

int i;

for(i=0;i<100;i++){

if(num[i]%2==0)

printf("%d - I love CodeChum\n", num[i]);

return 0;

//output
--padayon future engineer, it always seems impossible until it's done. (kana lang sa kay nahutdan nakog
quotes hahahaha)

You might also like