0% found this document useful (0 votes)
7 views2 pages

C Language - Example of Loops

The document outlines various programming tasks comparing Scratch blocks with C language code. It includes examples for creating loops to print 'meow', counting down to Ramadan, and printing a multiplication table. Each task is accompanied by corresponding code snippets in both Scratch and C language.

Uploaded by

marwailyas816
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)
7 views2 pages

C Language - Example of Loops

The document outlines various programming tasks comparing Scratch blocks with C language code. It includes examples for creating loops to print 'meow', counting down to Ramadan, and printing a multiplication table. Each task is accompanied by corresponding code snippets in both Scratch and C language.

Uploaded by

marwailyas816
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/ 2

No.

Program Scratch Blocks C Language


Function
1 This program will say meow forever in Forever Block int i = 1;
the Scratch Program Say Meow for 2
& secs while (i < 10)
This program will print meow forever in Wait 0.2 secs {
the screen
printf(“meow”);
}

2 This program will say meow 10 times Repeat 10 times int i = 1;


in the Scratch Program say Meow for 2
& secs while (i < = 10)
This program will print meow forever in wait 0.2 secs {
the screen printf(“Meow”);
i = i + 1;
}

3 This program will print numbers from 1 #include <stdio.h>


to 10
(incrementing) int main()
{
int i=1;
while (i<=10)
{
printf("%d\n",
i);
i = i + 1;
}

return 0;
}
Think:
No Program C Language Code

4 Ramadan Count int main(void)


down {

int counter = 3;

printf("Today is December 01, 2024\n");


printf("Three months are left to Ramadan\n");
printf("Lets make a Ramadan Count down in C language\n");

while (counter > -1 )


{
printf("%d months left\n", counter);
counter = counter - 1;
}

printf("Alhumdulillah, we have reached Ramadan 2025\n");

return 0;
}

5 Print Times #include <stdio.h>


Table int main()
{
int table;
int range;
int i=0;

printf("\nwhich table you want to print:");


scanf ("%d", &table);

printf("\nEnter range:");
scanf ("%d", &range);

while(i < range)


{
printf("%d * %d = %d\n", table, i, table*i);
i=i+1;
}
return 0;
}

You might also like