GeeksforGeeks » Object oriented queries
Using console application to create this program.
(6 posts)-
Can you specify a porgram to print the numbers from 1 to 10 and their squares without using a loop?
-
#include <stdio.h> /* Prints numbers from 1 to n */ void printNos(unsigned int n) { if(n > 0) { printNos(n-1); printf("%d --> %d\n", n, n*n); } return; } /* Driver program to test printNos */ int main() { printNos(10); getchar(); return 0; } -
void main() { static int i=0; switch(i) { case 10: exit(0); default: printf("\n%d >>> >>> >>> %d",i++,I*i); } main(); } -
nice logic pranay, but 10 is also included.
-
oops! my bad,
just change the case 10 to case 11 :) -
#include <stdio.h> int disp(int i) { printf(" i = %d square %d\n", i, i*i); return (i ^ 10) && disp(-(~i)); } int main(void) { disp(1); }
Reply
You must log in to post.