APC-PRAC-023.c (1160B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 12 Dec 2025 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* Pattern : 9 (a) 1, -3, 5, -7, 9, -11, ... upto n times 10 (b) 0, 3, 8, 15, ... upto n times 11 */ 12 // File Name - amit0711202505.c (LAB), APC-PRAC-023.c (Local) 13 14 // This code has not been compiled. 15 // If you find any issues, please create a new issue on GitHub regarding them. 16 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 17 18 #include <stdio.h> 19 #include <stdbool.h> 20 21 int main() 22 { 23 int n, i, temp = 1; 24 bool isNegative = true; 25 printf("Enter the n : "); 26 scanf("%d", &n); 27 printf("\nPattern A :"); 28 for (i = 1; i <= n; i++) 29 { 30 if (!isNegative) 31 { 32 printf(" %d", temp * -1); 33 isNegative = true; 34 } 35 else 36 { 37 printf(" %d", temp); 38 isNegative = false; 39 } 40 temp += 2; 41 } 42 printf("\nPattern B :"); 43 for (i = 1; i <= n; i++) 44 { 45 temp = (i * i) - 1; 46 printf(" %d", temp); 47 } 48 return 0; 49 }