bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / APC-PRAC-023.c

APC-PRAC-023.c (969B)


      1 /* Pattern :
      2     (a) 1, -3, 5, -7, 9, -11, ... upto n times
      3     (b) 0, 3, 8, 15, ... upto n times
      4 */
      5 // File Name - amit0711202505.c (LAB), APC-PRAC-023.c (Local)
      6 
      7 // This code has not been compiled.
      8 // If you find any issues, please create a new issue on GitHub regarding them.
      9 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     10 
     11 #include <stdio.h>
     12 #include <stdbool.h>
     13 
     14 int main()
     15 {
     16     int n, i, temp = 1;
     17     bool isNegative = true;
     18     printf("Enter the n : ");
     19     scanf("%d", &n);
     20     printf("\nPattern A :");
     21     for (i = 1; i <= n; i++)
     22     {
     23         if (!isNegative)
     24         {
     25             printf("  %d", temp * -1);
     26             isNegative = true;
     27         }
     28         else
     29         {
     30             printf("  %d", temp);
     31             isNegative = false;
     32         }
     33         temp += 2;
     34     }
     35     printf("\nPattern B :");
     36     for (i = 1; i <= n; i++)
     37     {
     38         temp = (i * i) - 1;
     39         printf("  %d", temp);
     40     }
     41     return 0;
     42 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror