#include<stdio.h> int FindX(int n) { int sum, count; for(int j = 1; sum <= n;j++) { sum = sum + j; if(sum > n) { break; } count = count + 1; } return count; } void main() { int n; printf("enter n: "); do { scanf("%d", &n); if(n < 0) { printf("n must greater than 0") } }while(n < 0) printf("X = %d", FindX(n)); getch(); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter