#include <stdio.h>
int main() {
// Write C++ code here
int i=1,j;
printf("Enter the number you wish to print: ");
scanf("%d", &j);
printf("\nUsing while loop:\n");
while (i<=j)
{
printf("%d\t",i);
i++;
}
i--;
printf("\n\nOn the Reverse Order:\n");
while (i>=1)
{
printf("%d\t",i);
i--;
}
printf("\n\nUsing for loop:\n");
for (i=1;i<=j;i++)
{
printf("%d\t",i);
}
i--;
printf("\n\nOn the Reverse Order:\n");
for (;i>=1;i--)
{
printf("%d\t",i);
}
printf("\n\nUsing for do while:\n");
do { printf("%d\t",i),
i++; }
while (i<=j);
i--;
printf("\n\nOn the Reverse Order:\n");
do { printf("%d\t",i);
i--; }
while (i>=1);
return 0;
}
int main() {
// Write C++ code here
int i, RN;
printf("Enter the number: ");
scanf("%d",&i);
for (int j=1; j <= i; j++)
{
if (i % j == 0)
{
printf("%d\n",j);}
}
while ( i != 0)
{ int digit = i % 10;
RN = RN * 10 + digit;
i = i / 10; }
printf("reversed number: %d\n", RN);
return 0;
}
Replies to CSE 2.1 CL2
Title |
Name |
Language |
UNIX |
When |
Re: CSE 2.1 CL2 |
CL4 |
text |
1693479279 |
1 Year ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}